diff --git a/.github/workflows/test-lang-go.yml b/.github/workflows/test-lang-go.yml new file mode 100644 index 00000000..1bd66caa --- /dev/null +++ b/.github/workflows/test-lang-go.yml @@ -0,0 +1,32 @@ +name: test-lang-go +on: [pull_request] +jobs: + lang-go-test: + name: "Lang Go test (ver: ${{ matrix.go-version.go }}) (os: ${{ matrix.os }})" + runs-on: ${{ matrix.os }} + strategy: + matrix: + go-version: [{go: "1.22", yaegi: "v0.16.1"}, {go: "1.19", yaegi: "v0.14.0"}, {go: "1.18", yaegi: "v0.14.0"}, {go: "1.17", yaegi: "v0.13.0"}, {go: "1.16", yaegi: "v0.13.0"}] + os: [ubuntu-22.04, macos-26-intel] + include: + - os: ubuntu-22.04 + python-version: "3.7.17" + - os: macos-26-intel + python-version: "3.12" + steps: + - uses: actions/checkout@v4 + - name: Setup python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py + - name: Setup go + uses: actions/setup-go@v6 + with: + go-version: ${{ matrix.go-version.go }} + - run: go version + - run: make deps-dev + - run: make install-from-pkg-tgz + - run: go install github.com/traefik/yaegi/cmd/yaegi@${{ matrix.go-version.yaegi }} + - run: PATH=$PATH:$(go env GOPATH)/bin make lang-go-test diff --git a/.github/workflows/test-lang-iasm.yml b/.github/workflows/test-lang-iasm.yml new file mode 100644 index 00000000..f7a1651f --- /dev/null +++ b/.github/workflows/test-lang-iasm.yml @@ -0,0 +1,26 @@ +name: test-lang-iasm +on: [pull_request] +jobs: + lang-iasm-test: + name: "Lang iasm test (ver: latest) (os: ${{ matrix.os }})" + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-22.04, macos-26-intel] + include: + - os: ubuntu-22.04 + python-version: "3.7.17" + - os: macos-26-intel + python-version: "3.12" + steps: + - uses: actions/checkout@v4 + - name: Setup python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py + - run: make deps-dev + - run: make install-from-pkg-tgz + - run: pip install iasm + - run: make lang-iasm-test diff --git a/.github/workflows/test-lang-java.yml b/.github/workflows/test-lang-java.yml new file mode 100644 index 00000000..8df7c956 --- /dev/null +++ b/.github/workflows/test-lang-java.yml @@ -0,0 +1,31 @@ +name: test-lang-java +on: [pull_request] +jobs: + lang-java-test: + name: "Lang Java test (ver: ${{ matrix.java }}) (os: ${{ matrix.os }})" + runs-on: ${{ matrix.os }} + strategy: + matrix: + java: [ '13', '15', '17', '21', '24' ] + os: [ubuntu-22.04, macos-26-intel] + include: + - os: ubuntu-22.04 + python-version: "3.7.17" + - os: macos-26-intel + python-version: "3.12" + steps: + - uses: actions/checkout@v4 + - name: Setup python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py + - name: Setup java + uses: actions/setup-java@v5 + with: + distribution: 'zulu' + java-version: ${{ matrix.java }} + - run: make deps-dev + - run: make install-from-pkg-tgz + - run: make lang-java-test diff --git a/.github/workflows/test-lang-javascript.yml b/.github/workflows/test-lang-javascript.yml new file mode 100644 index 00000000..a7caea44 --- /dev/null +++ b/.github/workflows/test-lang-javascript.yml @@ -0,0 +1,30 @@ +name: test-lang-javascript +on: [pull_request] +jobs: + lang-javascript-test: + name: "Lang Javascript test (ver: ${{ matrix.node-version }}) (os: ${{ matrix.os }})" + runs-on: ${{ matrix.os }} + strategy: + matrix: + node-version: [10.x, 12.x, 14.x, 15.x, 16.x, 18.x, 20.x, 22.x, 23.x] + os: [ubuntu-22.04, macos-26-intel] + include: + - os: ubuntu-22.04 + python-version: "3.7.17" + - os: macos-26-intel + python-version: "3.12" + steps: + - uses: actions/checkout@v4 + - name: Setup python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py + - name: Setup Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v6 + with: + node-version: ${{ matrix.node-version }} + - run: make deps-dev + - run: make install-from-pkg-tgz + - run: make lang-javascript-test diff --git a/.github/workflows/test-lang-ruby.yml b/.github/workflows/test-lang-ruby.yml new file mode 100644 index 00000000..26f02e23 --- /dev/null +++ b/.github/workflows/test-lang-ruby.yml @@ -0,0 +1,30 @@ +name: test-lang-ruby +on: [pull_request] +jobs: + lang-ruby-test: + name: "Lang Ruby test (ver: ${{ matrix.ruby-version }}) (os: ${{ matrix.os }})" + runs-on: ${{ matrix.os }} + strategy: + matrix: + ruby-version: ["2.4", "2.5", "2.6", "2.7", "3.0", "3.1", "3.2", "3.3", "3.4", "4.0"] + os: [ubuntu-22.04, macos-26-intel] + include: + - os: ubuntu-22.04 + python-version: "3.7.17" + - os: macos-26-intel + python-version: "3.12" + steps: + - uses: actions/checkout@v4 + - name: Setup python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py + - name: Setup ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby-version }} + - run: make deps-dev + - run: make install-from-pkg-tgz + - run: make lang-ruby-test diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 2240c03a..f073184f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,21 +1,48 @@ name: test on: [pull_request] jobs: - byexample-test: + byexample-linux-test: name: "Byexample Python (ver: ${{ matrix.python-version }}) (os: ${{ matrix.os }})" runs-on: ${{ matrix.os }} strategy: matrix: python-version: ["3.7.17", "3.8.18", "3.9.25", "3.10.20", "3.11.15", "3.12.13", "3.13.12", "3.14.3"] - os: [ubuntu-22.04, macos-26] + os: [ubuntu-22.04] env: TERM: xterm-color steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py + - run: make deps-dev + - run: make install-from-pkg-tgz + - run: make lib-test + - run: make modules-test + - run: make docs-test + - run: make examples-test + - run: make corner-test + + byexample-mac-test: + name: "Byexample Python (ver: ${{ matrix.python-version }}) (os: ${{ matrix.os }})" + runs-on: ${{ matrix.os }} + strategy: + matrix: + python-version: ["3.12", "3.13", "3.14"] + os: [macos-26-intel] + env: + TERM: xterm-color + steps: + - uses: actions/checkout@v4 + - name: Setup python + uses: actions/setup-python@v6 + with: + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py - run: make deps-dev - run: make install-from-pkg-tgz - run: make lib-test @@ -28,11 +55,13 @@ jobs: name: "Source code" runs-on: ubuntu-22.04 steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: "3.7.17" + cache: 'pip' + cache-dependency-path: setup.py - run: make deps-dev - run: make format-test @@ -40,7 +69,7 @@ jobs: name: "Github Pages test" runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup ruby uses: ruby/setup-ruby@v1 with: @@ -50,153 +79,69 @@ jobs: lang-python-test: name: "Lang Python test (ver: ${{ matrix.python-version }}) (os: ${{ matrix.os }})" - runs-on: ubuntu-24.04 + runs-on: ${{ matrix.os }} strategy: matrix: python-version: ["3.11.15", "3.12.13", "3.13.12", "3.14.3"] os: [ubuntu-24.04] steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py - run: make deps-dev - run: make install-from-pkg-tgz - run: make lang-python-test - lang-iasm-test: - name: "Lang iasm test (ver: latest) (os: ${{ matrix.os }})" - runs-on: ${{ matrix.os }} - strategy: - matrix: - os: [ubuntu-22.04, macos-26] - steps: - - uses: actions/checkout@v2 - - name: Setup python - uses: actions/setup-python@v2 - with: - python-version: "3.7.17" - - run: make deps-dev - - run: make install-from-pkg-tgz - - run: pip install iasm - - run: make lang-iasm-test lang-pwsh-test: name: "Lang PowerShell test (ver: latest) (os: ${{ matrix.os }})" runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, macos-26] + os: [ubuntu-22.04, macos-26-intel] + include: + - os: ubuntu-22.04 + python-version: "3.7.17" + - os: macos-26-intel + python-version: "3.12" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: - python-version: "3.7.17" + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py - run: make deps-dev - run: make install-from-pkg-tgz - run: make lang-pwsh-test - lang-ruby-test: - name: "Lang Ruby test (ver: ${{ matrix.ruby-version }}) (os: ${{ matrix.os }})" - runs-on: ${{ matrix.os }} - strategy: - matrix: - ruby-version: ["2.4", "2.5", "2.6", "2.7", "3.0", "3.1"] - os: [ubuntu-22.04, macos-26] - steps: - - uses: actions/checkout@v2 - - name: Setup python - uses: actions/setup-python@v2 - with: - python-version: "3.7.17" - - name: Setup ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby-version }} - - run: make deps-dev - - run: make install-from-pkg-tgz - - run: make lang-ruby-test lang-shell-test: name: "Lang Shell test (ver: latest) (os: ${{ matrix.os }})" runs-on: ${{ matrix.os }} strategy: matrix: - os: [ubuntu-22.04, macos-26] + os: [ubuntu-22.04, macos-26-intel] + include: + - os: ubuntu-22.04 + python-version: "3.7.17" + - os: macos-26-intel + python-version: "3.12" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Setup python - uses: actions/setup-python@v2 + uses: actions/setup-python@v6 with: - python-version: "3.7.17" + python-version: ${{ matrix.python-version }} + cache: 'pip' + cache-dependency-path: setup.py - run: make deps-dev - run: make install-from-pkg-tgz - run: make lang-shell-test - lang-javascript-test: - name: "Lang Javascript test (ver: ${{ matrix.node-version }}) (os: ${{ matrix.os }})" - runs-on: ${{ matrix.os }} - strategy: - matrix: - node-version: [10.x, 12.x, 14.x, 15.x, 16.x] - os: [ubuntu-22.04, macos-26] - steps: - - uses: actions/checkout@v2 - - name: Setup python - uses: actions/setup-python@v2 - with: - python-version: "3.7.17" - - name: Setup Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2 - with: - node-version: ${{ matrix.node-version }} - - run: make deps-dev - - run: make install-from-pkg-tgz - - run: make lang-javascript-test - - lang-go-test: - name: "Lang Go test (ver: ${{ matrix.go-version.go }}) (os: ${{ matrix.os }})" - runs-on: ${{ matrix.os }} - strategy: - matrix: - go-version: [{go: "1.19", yaegi: "v0.14.0"}, {go: "1.18", yaegi: "v0.14.0"}, {go: "1.17", yaegi: "v0.13.0"}, {go: "1.16", yaegi: "v0.13.0"}] - os: [ubuntu-22.04, macos-26] - steps: - - uses: actions/checkout@v2 - - name: Setup python - uses: actions/setup-python@v2 - with: - python-version: "3.7" - - name: Setup go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version.go }} - - run: go version - - run: make deps-dev - - run: make install-from-pkg-tgz - - run: go install github.com/traefik/yaegi/cmd/yaegi@${{ matrix.go-version.yaegi }} - - run: PATH=$PATH:$(go env GOPATH)/bin make lang-go-test - lang-java-test: - name: "Lang Java test (ver: ${{ matrix.java }}) (os: ${{ matrix.os }})" - runs-on: ${{ matrix.os }} - strategy: - matrix: - java: [ '11', '13', '15' ] - os: [ubuntu-22.04, macos-26] - steps: - - uses: actions/checkout@v2 - - name: Setup python - uses: actions/setup-python@v2 - with: - python-version: "3.7" - - name: Setup java - uses: actions/setup-java@v2 - with: - distribution: 'zulu' - java-version: ${{ matrix.java }} - - run: make deps-dev - - run: make install-from-pkg-tgz - - run: make lang-java-test diff --git a/byexample/expected.py b/byexample/expected.py index a1272c94..5544d36b 100644 --- a/byexample/expected.py +++ b/byexample/expected.py @@ -348,7 +348,7 @@ def _get_captures_by_incremental_match( >>> expected = r'aa<...>bb<...>ddd<...>eee<...>cc' >>> got = r'aaAAbbBBxxxddeeeCCcc' - >>> expected_regexs = ['\A', 'aa', '(.*?)', 'bb', '(.*?)', 'ddd', + >>> expected_regexs = ['\\A', 'aa', '(.*?)', 'bb', '(.*?)', 'ddd', ... '(.*?)', 'eee', '(.*?)', 'cc', r'\n*\Z'] >>> charnos = [0, 0, 2, 7, 9, 14, 17, 22, 25, 30, 32] >>> rcounts = [0, 2, 0, 2, 0, 3, 0, 3, 0, 2, 0] @@ -396,7 +396,7 @@ def _get_captures_by_incremental_match( >>> expected = r'aabbdddeeecc' >>> got = r'aaAAbbBBxxxddeeeCCcc' - >>> expected_regexs = ['\A', 'aa', '(?P.*?)', 'bb', + >>> expected_regexs = ['\\A', 'aa', '(?P.*?)', 'bb', ... '(?P.*?)', 'ddd', '(?P.*?)', ... 'eee', '(?P.*?)', 'cc', r'\n*\Z'] >>> charnos = [0, 0, 2, 7, 9, 14, 17, 22, 25, 30, 32] @@ -423,7 +423,7 @@ def _get_captures_by_incremental_match( >>> expected = 'aabb\ncc\nddee' >>> got = 'aaAAbb\nxx\nxxAAee' - >>> expected_regexs = ['\A', 'aa', '(?P.*?)', 'bb\n', + >>> expected_regexs = ['\\A', 'aa', '(?P.*?)', 'bb\n', ... 'cc\n', 'dd', '(?P.*?)', ... 'ee', r'\n*\Z'] >>> charnos = [0, 0, 2, 7, 10, 13, 15, 20, 22] @@ -442,7 +442,7 @@ def _get_captures_by_incremental_match( >>> expected = 'aabb\ncc\nddee' - >>> expected_regexs = ['\A', 'aa', '(?P.*?)', 'bb\n', + >>> expected_regexs = ['\\A', 'aa', '(?P.*?)', 'bb\n', ... 'cc\n', 'dd', '(?P=foo)', ... 'ee', r'\n*\Z'] >>> rcounts = [0, 2, 0, 3, 3, 2, 1, 2, 0] # notice the +1 diff --git a/byexample/log.py b/byexample/log.py index 9baf3be6..1ebda035 100644 --- a/byexample/log.py +++ b/byexample/log.py @@ -334,6 +334,7 @@ def log_with(logger_name, child=True): finally: _logger_stack.pop() + class _DummyRLock: ''' A dummy reentrant lock to emulate a lock (acquire/release) but without @@ -364,6 +365,7 @@ def __enter__(self): def __exit__(self, exc_type, exc_value, traceback): self.release() + class XStreamHandler(logging.StreamHandler): def __init__(self, *args, **kargs): logging.StreamHandler.__init__(self, *args, **kargs) diff --git a/byexample/prof.py b/byexample/prof.py index a734c07e..0d52aa18 100644 --- a/byexample/prof.py +++ b/byexample/prof.py @@ -23,10 +23,11 @@ with the elapsed time in nanoseconds: >>> foo() # byexample: +timeout=8 -stdin>::foo 1<...> +stdin<...>::foo 1<...> The function name is prefixed by the name of the module. In this case, -"stdin>". +"stdin>" plus some prefix like "stdin>-11" or "stdin-11>" +(but this prefix depends on the Python version used). Nested profiled functions will print a larger stack trace: @@ -36,8 +37,8 @@ ... foo() >>> gus() # byexample: +timeout=8 +paste -stdin>::gus;stdin>::foo 1<...> -stdin>::gus 2<...> +stdin<...>::gus;stdin<...>::foo 1<...> +stdin<...>::gus 2<...> Two one-liner stack traces were printed: one for foo() called from gus() and the other for gus() only. @@ -63,7 +64,7 @@ ... time.sleep(2) >>> bar() # byexample: +timeout=8 -stdin>::bar 2<...> +stdin<...>::bar 2<...> By default the context manager uses the name of the calling function for the stack trace. @@ -78,8 +79,8 @@ ... time.sleep(2) >>> baz() # byexample: +timeout=8 -stdin>::baz::head 1<...> -stdin>::baz::tail 2<...> +stdin<...>::baz::head 1<...> +stdin<...>::baz::tail 2<...> Nested is possible too: @@ -92,9 +93,9 @@ ... time.sleep(3) >>> nested() # byexample: +timeout=12 -stdin>::nested;stdin>::nested;stdin>::nested 3<...> -stdin>::nested;stdin>::nested 2<...> -stdin>::nested 1<...> +stdin<...>::nested;stdin<...>::nested;stdin<...>::nested 3<...> +stdin<...>::nested;stdin<...>::nested 2<...> +stdin<...>::nested 1<...> The engine is thread safe. Due how the engine works the traces may be written out of order and they may be diff --git a/docs/languages/python.md b/docs/languages/python.md index 872ad708..f9a616a5 100644 --- a/docs/languages/python.md +++ b/docs/languages/python.md @@ -372,7 +372,7 @@ executed and with the output returned by the interpreter. >>> sys Traceback <...> -NameError: name 'sys' is not defined +NameError: name 'sys' is not defined<...> ``` ### Empty lines diff --git a/docs/overview/usage.md b/docs/overview/usage.md index bcd72ea8..e20b67ee 100644 --- a/docs/overview/usage.md +++ b/docs/overview/usage.md @@ -89,7 +89,7 @@ The help included in ``byexample`` should give you a quick overview of its capabilities ``` -$ byexample -h # byexample: +norm-ws -tags +rm=  +diff=ndiff +$ byexample -h # byexample: +norm-ws -capture +rm=  +diff=ndiff usage: byexample -l [--ff] [--timeout ] [-j ] [--dry] [--skip [ ...]] [--capture-env-var ] [-d {none,unified,ndiff,context,tool}] [--difftool ] @@ -105,7 +105,7 @@ positional arguments: files that have the examples to run.   Language Selection: - -l , --language , --languages + -l<...> --language<...> --languages select which languages to parse and run. Comma separated syntax is also accepted.   @@ -114,21 +114,21 @@ Execution Options: --timeout timeout in seconds to complete each example (2 by default); this can be changed per example with this option. - -j , --jobs run jobs in parallel (1 by default); can be an + -j<...> --jobs run jobs in parallel (1 by default); can be an integer or the string "cpu" or "cpu": "cpu" means use all the cpus available; "cpu" multiply it by the cpus available. --dry do not run any example, only parse them. --skip [ ...] skip these files - --capture-env-var , --capture-env-vars + --capture-env-var<...> --capture-env-vars capture some environment variables and put them in the clipboard so they can be pasted and used in conditional executions. Comma separated syntax is also accepted.   Diff Options: - -d {none,unified,ndiff,context,tool}, --diff {none,unified,ndiff,context,tool} + -d<...> --diff {none,unified,ndiff,context,tool} select diff algorithm (none by default). --difftool command line to the external diff program; the tokens %e and %g are replaced by the file names with the @@ -140,12 +140,12 @@ Diff Options: disables all of that.   Miscellaneous Options: - -o , --options + -o<...> --options add additional options; see --show-options to list them. --show-options show the available options for the selected languages (with -l) - -m , --modules + -m<...> --modules append a directory for searching modules there. --encoding [:] select the encoding and optionally the error handler diff --git a/docs/recipes/arguments-per-environment.md b/docs/recipes/arguments-per-environment.md index 1066f7b8..70bf5b8a 100644 --- a/docs/recipes/arguments-per-environment.md +++ b/docs/recipes/arguments-per-environment.md @@ -1,7 +1,6 @@