diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f9ff761..d20602c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -192,9 +192,26 @@ After running tests, inspect the console output to see if there were any errors #### Adding tests -The PyPi tests are implemented in `docker/test/run_pypi_tests.sh`. If you find a bug, then adding a test to this script +The PyPi tests are implemented in `docker/test/shell_tests.sh`. If you find a bug, then adding a test to this script could be useful, and quicker than adding a unittest. +### CLI tests + +To run the CLI tests that execute as part of the `inv test.pypi` against a local install you can use: + +```bash +inv test.cli +``` + +If you would like to build, install and run the cli tests against a local install (which can be useful when editing +CLI code), you can use: + +```bash +inv build && inv install && inv test.cli +``` + +Note that this will force install the built wheel from the project `dist/` directory over any existing local install. + ## Documentation The `README.md` file contains a table showing example badges for the different built-in colors. If you modify the diff --git a/tasks/test.py b/tasks/test.py index 1820904..ac2f23b 100644 --- a/tasks/test.py +++ b/tasks/test.py @@ -52,3 +52,20 @@ def pypi(c, version="latest"): f"docker run -e VERSION={version} -v {test_files.absolute()}:/test_files test-anybadge:latest /work/run_pypi_tests.sh", shell=True, ) + + +@task +def cli(c, version="latest"): + """Run CLI tests against currently installed version.""" + print("Running tests against currently installed version...") + + clean(c) + test_files = PROJECT_DIR / Path("test_files") + test_files.mkdir(exist_ok=True) + + shell_test = PROJECT_DIR / Path("docker/test/shell_tests.sh") + + subprocess.run( + f'SOURCE_DIR="{shell_test.parent}" PROJECT_DIR="{PROJECT_DIR}" {shell_test}', + shell=True, + )