From 62a142bd8981eeaaa72b270e6caf330fc8f05245 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Sun, 26 Dec 2021 21:31:24 +0100 Subject: [PATCH 01/15] Add tox support to cram workspace This commit introduces a tox.ini file which mimiks the behaviour of the Makefile which is used for verifying and testing the cram project. Attention: The build and install step is not explicitly added, because tox already takes care about this by default. See also: https://tox.wiki/en/latest/index.html For now tox just will simplify the local and the CI multi environment test execution. In case the Makefile path will be removed in the future, the tox.ini could be improved to more cleanly seperate different concerns like: linting, coverage, integratin testing, unit testing etc. --- .gitignore | 1 + .travis.yml | 49 +++++------------------------------------------- MANIFEST.in | 2 +- requirements.txt | 1 + tests/pyflakes.t | 2 +- tox.ini | 22 ++++++++++++++++++++++ 6 files changed, 31 insertions(+), 46 deletions(-) create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore index d6cdf627..a2bee191 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.tox *.orig *.rej *~ diff --git a/.travis.yml b/.travis.yml index 8ffa259d..af436819 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,54 +1,20 @@ language: python +addons: + apt: + packages: + - zsh matrix: allow_failures: - python: nightly - env: TESTOPTS=--shell=dash - - python: pypy - env: TESTOPTS=--shell=dash - python: pypy3 - env: TESTOPTS=--shell=dash include: - python: "3.5" - env: TESTOPTS=--shell=dash - - python: "3.5" - env: TESTOPTS=--shell=bash - - python: "3.5" - env: TESTOPTS=--shell=zsh - addons: - apt: - packages: - - zsh - python: "3.4" - env: TESTOPTS=--shell=dash - python: "3.3" - env: TESTOPTS=--shell=dash - python: "3.2" - env: TESTOPTS=--shell=dash - - python: "2.7" - env: TESTOPTS=--shell=dash - - python: "2.6" - env: TESTOPTS=--shell=dash - - env: PYTHON=2.5 TESTOPTS=--shell=dash - addons: - apt: - sources: - - deadsnakes - packages: - - python2.5 - - env: PYTHON=2.4 TESTOPTS=--shell=dash - addons: - apt: - sources: - - deadsnakes - packages: - - python2.4 - python: nightly - env: TESTOPTS=--shell=dash - - python: pypy - env: TESTOPTS=--shell=dash - python: pypy3 - env: TESTOPTS=--shell=dash fast_finish: true install: | @@ -59,9 +25,4 @@ install: | fi script: | - if [ -z "$PYTHON" ] - then - make test TESTOPTS="$TESTOPTS" - else - make quicktest PYTHON="python$PYTHON" - fi + tox diff --git a/MANIFEST.in b/MANIFEST.in index f4751b6e..905b45d5 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,4 @@ -include .coveragerc .pylintrc .travis.yml Makefile MANIFEST.in +include .coveragerc .pylintrc .travis.yml Makefile MANIFEST.in tox.ini include *.md *.rst *.txt contrib/* scripts/* exclude contrib/PKGBUILD recursive-include examples *.t diff --git a/requirements.txt b/requirements.txt index dbabc261..685e0568 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ check-manifest coverage pycodestyle pyflakes +tox diff --git a/tests/pyflakes.t b/tests/pyflakes.t index 1a2a806b..8dffc9cd 100644 --- a/tests/pyflakes.t +++ b/tests/pyflakes.t @@ -4,4 +4,4 @@ Skip this test if pyflakes isn't available: Check that there are no obvious Python source code errors: - $ pyflakes "$TESTDIR/.." + $ pyflakes "$TESTDIR/../cram" diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..3f853e66 --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +[tox] +#TODO: adjust set of used python interpreter(s) +envlist=py3-{integration}-{dash,bash,zsh},py3-{coverage} + +[testenv] +setenv = + PYTHONPATH = {envpython} + PYTHONPATH = {toxinidir} + dash: TESTOPTS = --shell=dash + bash: TESTOPTS = --shell=bash + zsh: TESTOPTS = --shell=zsh +deps = + -r{toxinidir}/requirements.txt + +commands = + integration: cram {env:TESTOPTS:--shell=dash} {toxinidir}/tests + +[testenv:coverage] +setenv = + COVERAGE = coverage +commands = + coverage report --fail-under=100 \ No newline at end of file From d2cd35d40637f62ca4aab5ca71111ae26c73799b Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Sun, 26 Dec 2021 22:57:26 +0100 Subject: [PATCH 02/15] Drop support for all unsupported python versions --- .travis.yml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index af436819..e1328fc2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,10 +9,9 @@ matrix: - python: nightly - python: pypy3 include: - - python: "3.5" - - python: "3.4" - - python: "3.3" - - python: "3.2" + - python: "3.9" + - python: "3.8" + - python: "3.7" - python: nightly - python: pypy3 fast_finish: true From dd600b6cf259946be5c5837f3aecaaa6b97472a5 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Mon, 27 Dec 2021 09:41:29 +0100 Subject: [PATCH 03/15] Replace try finally with with block --- cram/_test.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cram/_test.py b/cram/_test.py index 2cec870d..89c3ca59 100644 --- a/cram/_test.py +++ b/cram/_test.py @@ -209,8 +209,7 @@ def testfile(path, shell='/bin/sh', indent=2, env=None, cleanenv=True, :return: Input, output, and diff iterables :rtype: (list[bytes], list[bytes], collections.Iterable[bytes]) """ - f = open(path, 'rb') - try: + with open(path, 'rb') as f: abspath = os.path.abspath(path) env = env or os.environ.copy() env['TESTDIR'] = os.fsdecode(os.path.dirname(abspath)) @@ -219,5 +218,3 @@ def testfile(path, shell='/bin/sh', indent=2, env=None, cleanenv=True, testname = os.path.basename(abspath) return test(f, shell, indent=indent, testname=testname, env=env, cleanenv=cleanenv, debug=debug) - finally: - f.close() From fd5898df0924618c78a66b93b1893dea7c7805de Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Mon, 27 Dec 2021 10:21:50 +0100 Subject: [PATCH 04/15] Introduce _cwd context manager --- cram/_run.py | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/cram/_run.py b/cram/_run.py index 43813a45..86a81b09 100644 --- a/cram/_run.py +++ b/cram/_run.py @@ -3,6 +3,8 @@ import os import sys +from contextlib import contextmanager + from cram._test import testfile __all__ = ['runtests'] @@ -30,6 +32,20 @@ def _findtests(paths): else: yield os.path.normpath(p) +@contextmanager +def _cwd(path): + """Change the working directory + + This context manager will change the working directory + and restore it afterwards. + """ + cwd = os.getcwd() + os.chdir(path) + try: + yield path + finally: + os.chdir(cwd) + def runtests(paths, tmpdir, shell, indent=2, cleanenv=True, debug=False): """Run tests and yield results. @@ -42,7 +58,6 @@ def runtests(paths, tmpdir, shell, indent=2, cleanenv=True, debug=False): (list of lines in the test, same list with actual output, diff) """ - cwd = os.getcwd() seen = set() basenames = set() for i, path in enumerate(_findtests(paths)): @@ -65,12 +80,9 @@ def test(): """Run test file""" testdir = os.path.join(tmpdir, basename) os.mkdir(testdir) - try: - os.chdir(testdir) + with _cwd(testdir): return testfile(abspath, shell, indent=indent, cleanenv=cleanenv, debug=debug, testname=path) - finally: - os.chdir(cwd) yield (path, test) From 381e3a452480c7b73450829a40080a517066c708 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Mon, 27 Dec 2021 10:22:14 +0100 Subject: [PATCH 05/15] Add more with blocks --- cram/_cli.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/cram/_cli.py b/cram/_cli.py index cad8381c..eee93822 100644 --- a/cram/_cli.py +++ b/cram/_cli.py @@ -101,12 +101,9 @@ def testwrapper(): if not quiet: _log('\n', None, verbose) - errfile = open(errpath, 'wb') - try: + with open(errpath, 'wb') as errfile: for line in postout: errfile.write(line) - finally: - errfile.close() if not quiet: origdiff = diff From 44494aea8f6d1a7cc8773c100907afa2b72a2515 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 09:31:16 +0100 Subject: [PATCH 06/15] Add github action for workspace verification --- .github/workflows/verifier.yaml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/verifier.yaml diff --git a/.github/workflows/verifier.yaml b/.github/workflows/verifier.yaml new file mode 100644 index 00000000..e518f3c2 --- /dev/null +++ b/.github/workflows/verifier.yaml @@ -0,0 +1,25 @@ +name: Cram Workspace Verfier + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.6", "3.7", "3.8", "3.9"] + + steps: + - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Full verification + run: | + tox \ No newline at end of file From d1a028aa51119961271849c8fb33044a1e1645f3 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 09:31:39 +0100 Subject: [PATCH 07/15] Remove travis ci build configuration/setup --- .travis.yml | 27 --------------------------- 1 file changed, 27 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index e1328fc2..00000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: python -addons: - apt: - packages: - - zsh - -matrix: - allow_failures: - - python: nightly - - python: pypy3 - include: - - python: "3.9" - - python: "3.8" - - python: "3.7" - - python: nightly - - python: pypy3 - fast_finish: true - -install: | - if [ -z "$PYTHON" ] - then - [ "$TRAVIS_PYTHON_VERSION" = "3.2" ] && pip install coverage==3.7.1 - pip install -r requirements.txt - fi - -script: | - tox From 6d8b080ae57386ecd50f5a5e969c5d413c18856b Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 09:32:43 +0100 Subject: [PATCH 08/15] Remove unsupported python version 3.6 from verification --- .github/workflows/verifier.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verifier.yaml b/.github/workflows/verifier.yaml index e518f3c2..e9ad4f03 100644 --- a/.github/workflows/verifier.yaml +++ b/.github/workflows/verifier.yaml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9"] + python-version: ["3.7", "3.8", "3.9"] steps: - uses: actions/checkout@v2 From 071c24f24ac1872cab4f6a1d5fd9c6c464206c17 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 09:33:35 +0100 Subject: [PATCH 09/15] Add newline at the end of file --- .github/workflows/verifier.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verifier.yaml b/.github/workflows/verifier.yaml index e9ad4f03..c57419a1 100644 --- a/.github/workflows/verifier.yaml +++ b/.github/workflows/verifier.yaml @@ -22,4 +22,4 @@ jobs: if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Full verification run: | - tox \ No newline at end of file + tox From 728ea33de4594faac876e02e2840e431b6bd0d72 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 09:39:26 +0100 Subject: [PATCH 10/15] Add bash, zsh to verifier dependencies --- .github/workflows/verifier.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/verifier.yaml b/.github/workflows/verifier.yaml index c57419a1..a16245cc 100644 --- a/.github/workflows/verifier.yaml +++ b/.github/workflows/verifier.yaml @@ -18,6 +18,8 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | + apt-get install bash + apt-get install zsh python -m pip install --upgrade pip if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Full verification From 485b2b42a27ad84f1cc8faf9039a32c3d72d362d Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 09:42:20 +0100 Subject: [PATCH 11/15] Fix apt commands for installing required shell(s) --- .github/workflows/verifier.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/verifier.yaml b/.github/workflows/verifier.yaml index a16245cc..f18d11a6 100644 --- a/.github/workflows/verifier.yaml +++ b/.github/workflows/verifier.yaml @@ -18,8 +18,8 @@ jobs: python-version: ${{ matrix.python-version }} - name: Install dependencies run: | - apt-get install bash - apt-get install zsh + sudo apt-get install -y bash + sudo apt-get install -u zsh python -m pip install --upgrade pip if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Full verification From 2ca4cfce360fa727115d01d2156c4110cc9c0cfa Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 09:57:47 +0100 Subject: [PATCH 12/15] Replace md5 command with md5sum command --- tests/interactive.t | 12 ++++++------ tests/test.t | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/interactive.t b/tests/interactive.t index 661b2002..e13eb82f 100644 --- a/tests/interactive.t +++ b/tests/interactive.t @@ -44,7 +44,7 @@ Interactive mode (don't merge): # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5 examples/fail.t examples/fail.t.err + $ md5sum examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) @@ -92,7 +92,7 @@ Interactive mode (merge): # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5 examples/fail.t + $ md5sum examples/fail.t .*\b1d9e5b527f01fbf2d9b1c121d005108c\b.* (re) $ mv examples/fail.t.orig examples/fail.t @@ -136,7 +136,7 @@ Verbose interactive mode (answer manually and don't merge): \d (re) Accept this change? [yN] Accept this change? [yN] # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5 examples/fail.t examples/fail.t.err + $ md5sum examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ printf 'bad\n\n' | cram -v -i examples/fail.t @@ -177,7 +177,7 @@ Verbose interactive mode (answer manually and don't merge): \d (re) Accept this change? [yN] Accept this change? [yN] # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5 examples/fail.t examples/fail.t.err + $ md5sum examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) @@ -224,7 +224,7 @@ Verbose interactive mode (answer manually and merge): examples/fail.t: merged output # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5 examples/fail.t + $ md5sum examples/fail.t .*\b1d9e5b527f01fbf2d9b1c121d005108c\b.* (re) $ mv examples/fail.t.orig examples/fail.t @@ -281,7 +281,7 @@ Test missing patch(1) and patch(1) error: # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5 examples/fail.t examples/fail.t.err + $ md5sum examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm patch examples/fail.t.err diff --git a/tests/test.t b/tests/test.t index e1f74b12..ad23f926 100644 --- a/tests/test.t +++ b/tests/test.t @@ -8,7 +8,7 @@ Run cram examples: .s.!.s. # Ran 7 tests, 2 skipped, 1 failed. [1] - $ md5 examples/fail.t examples/fail.t.err + $ md5sum examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm examples/fail.t.err @@ -19,7 +19,7 @@ Run examples with bash: .s.!.s. # Ran 7 tests, 2 skipped, 1 failed. [1] - $ md5 examples/fail.t examples/fail.t.err + $ md5sum examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm examples/fail.t.err @@ -36,7 +36,7 @@ Verbose mode: examples/test.t: passed # Ran 7 tests, 2 skipped, 1 failed. [1] - $ md5 examples/fail.t examples/fail.t.err + $ md5sum examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm examples/fail.t.err From 747682722db5dd946b99512992ed7d4e3a8f714f Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 10:09:19 +0100 Subject: [PATCH 13/15] Make test for bash independent of the location of its binary --- tests/setup.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/setup.sh b/tests/setup.sh index 33a75392..79ee8117 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -2,7 +2,7 @@ # Bash doesn't expand aliases by default in non-interactive mode, so # we enable it manually if the test is run with --shell=/bin/bash. -[ "$TESTSHELL" = "/bin/bash" ] && shopt -s expand_aliases +[ -n "$BASH" ] && shopt -s expand_aliases # The $PYTHON environment variable should be set when running this test # from Python. From 080aac03b8687211c0102bf762d0d77574a9a403 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 11:15:09 +0100 Subject: [PATCH 14/15] Add python script to calculate md5 checksum(s) for files by providing a python based implementation of the md5 hasing tool, it will incrase the platform independence of cram tets using it. --- scripts/md5.py | 28 ++++++++++++++++++++++++++++ tests/interactive.t | 12 ++++++------ tests/md5.t | 31 +++++++++++++++++++++++++++++++ tests/setup.sh | 4 +++- tests/test.t | 6 +++--- 5 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 scripts/md5.py create mode 100644 tests/md5.t diff --git a/scripts/md5.py b/scripts/md5.py new file mode 100644 index 00000000..4325f240 --- /dev/null +++ b/scripts/md5.py @@ -0,0 +1,28 @@ +""" Cli tool to calculate the md5 checksum for one or multiple files """ +import sys +import argparse +from hashlib import md5 + + +def _create_parser(): + parser = argparse.ArgumentParser() + parser.add_argument( + 'files', + metavar='FILE', + type=argparse.FileType('rb'), + nargs='+' + ) + return parser + + +def main(argv=None): + parser = _create_parser() + args = parser.parse_args(argv) + for file in args.files: + hasher = md5() + hasher.update(file.read()) + print(hasher.hexdigest()) + + +if __name__ == '__main__': + sys.exit(main()) diff --git a/tests/interactive.t b/tests/interactive.t index e13eb82f..661b2002 100644 --- a/tests/interactive.t +++ b/tests/interactive.t @@ -44,7 +44,7 @@ Interactive mode (don't merge): # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5sum examples/fail.t examples/fail.t.err + $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) @@ -92,7 +92,7 @@ Interactive mode (merge): # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5sum examples/fail.t + $ md5 examples/fail.t .*\b1d9e5b527f01fbf2d9b1c121d005108c\b.* (re) $ mv examples/fail.t.orig examples/fail.t @@ -136,7 +136,7 @@ Verbose interactive mode (answer manually and don't merge): \d (re) Accept this change? [yN] Accept this change? [yN] # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5sum examples/fail.t examples/fail.t.err + $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ printf 'bad\n\n' | cram -v -i examples/fail.t @@ -177,7 +177,7 @@ Verbose interactive mode (answer manually and don't merge): \d (re) Accept this change? [yN] Accept this change? [yN] # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5sum examples/fail.t examples/fail.t.err + $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) @@ -224,7 +224,7 @@ Verbose interactive mode (answer manually and merge): examples/fail.t: merged output # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5sum examples/fail.t + $ md5 examples/fail.t .*\b1d9e5b527f01fbf2d9b1c121d005108c\b.* (re) $ mv examples/fail.t.orig examples/fail.t @@ -281,7 +281,7 @@ Test missing patch(1) and patch(1) error: # Ran 1 tests, 0 skipped, 1 failed. [1] - $ md5sum examples/fail.t examples/fail.t.err + $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm patch examples/fail.t.err diff --git a/tests/md5.t b/tests/md5.t new file mode 100644 index 00000000..b3cfd732 --- /dev/null +++ b/tests/md5.t @@ -0,0 +1,31 @@ +Set up cram alias and example tests: + + $ . "$TESTDIR"/setup.sh + +Make sure md5 is aliased to our python implementation: + + $ md5 -h | head -n 1 + usage: md5.py.* (re) + +Test md5 with a single input file: + + $ cat > input-1.txt < FOO BAR + > LOREM IPSUM + > LOREM IPSUM LOREM IPSUM + > EOF + + $ md5 input-1.txt + .*\b8832541c7c7fd2e8aed563c8e23a60f7\b.* (re) + +Test md5 with multiple input files: + + $ cat > input-2.txt < FOO BAR + > LOREM IPSUM LOREM IPSUM + > EOF + + $ md5 input-1.txt input-2.txt input-1.txt + .*\b8832541c7c7fd2e8aed563c8e23a60f7\b.* (re) + .*\b06c8eaf05708ec6d207d582a3f9bcc59\b.* (re) + .*\b8832541c7c7fd2e8aed563c8e23a60f7\b.* (re) diff --git a/tests/setup.sh b/tests/setup.sh index 79ee8117..f42c03c1 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -18,12 +18,14 @@ if [ -n "$COVERAGE" ]; then $TESTDIR/../scripts/cram --shell=$TESTSHELL" alias doctest="`which "$COVERAGE"` run -a --rcfile=$TESTDIR/../.coveragerc \ $TESTDIR/run-doctests.py" + alias md5="`which "$COVERAGE"` run -a --rcfile=$TESTDIR/../.coveragerc \ +$TESTDIR/../scripts/md5.py" else PYTHON="`command -v "$PYTHON" || echo "$PYTHON"`" alias cram="$PYTHON $TESTDIR/../scripts/cram --shell=$TESTSHELL" alias doctest="$PYTHON $TESTDIR/run-doctests.py" + alias md5="$PYTHON $TESTDIR/../scripts/md5.py" fi -command -v md5 > /dev/null || alias md5=md5sum # Copy in example tests cp -R "$TESTDIR"/../examples . diff --git a/tests/test.t b/tests/test.t index ad23f926..e1f74b12 100644 --- a/tests/test.t +++ b/tests/test.t @@ -8,7 +8,7 @@ Run cram examples: .s.!.s. # Ran 7 tests, 2 skipped, 1 failed. [1] - $ md5sum examples/fail.t examples/fail.t.err + $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm examples/fail.t.err @@ -19,7 +19,7 @@ Run examples with bash: .s.!.s. # Ran 7 tests, 2 skipped, 1 failed. [1] - $ md5sum examples/fail.t examples/fail.t.err + $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm examples/fail.t.err @@ -36,7 +36,7 @@ Verbose mode: examples/test.t: passed # Ran 7 tests, 2 skipped, 1 failed. [1] - $ md5sum examples/fail.t examples/fail.t.err + $ md5 examples/fail.t examples/fail.t.err .*\b0f598c2b7b8ca5bcb8880e492ff6b452\b.* (re) .*\b7a23dfa85773c77648f619ad0f9df554\b.* (re) $ rm examples/fail.t.err From 298ed7efd741bb0f08e9179b3f95bbc5be784614 Mon Sep 17 00:00:00 2001 From: Nicola Coretti Date: Tue, 28 Dec 2021 17:33:09 +0100 Subject: [PATCH 15/15] Add support for verifying pull_request --- .github/workflows/verifier.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/verifier.yaml b/.github/workflows/verifier.yaml index f18d11a6..b237530c 100644 --- a/.github/workflows/verifier.yaml +++ b/.github/workflows/verifier.yaml @@ -1,6 +1,6 @@ name: Cram Workspace Verfier -on: [push] +on: [push, pull_request] jobs: build: