diff options
| -rw-r--r-- | README.md | 33 | ||||
| l--------- | harness | 1 | ||||
| -rw-r--r-- | src/log.sh (renamed from lib/log.sh) | 0 | ||||
| -rwxr-xr-x | src/main.sh (renamed from main.sh) | 14 | ||||
| -rw-r--r-- | src/test.sh (renamed from lib/test.sh) | 0 |
5 files changed, 34 insertions, 14 deletions
@@ -8,22 +8,39 @@ Used in a bunch of projects of mine, for example: * [tag-release](https://github.com/egor-tensin/tag-release/tree/master/test) * [config-links](https://github.com/egor-tensin/config-links/tree/master/test) +Integration +----------- + +* Can be added as a submodule like so: + + > cd my/project/test + > git submodule add https://github.com/egor-tensin/test-harness.git runner + + * Run tests using the `harness` script: + + > ./test/runner/harness + + * This will pick up all test files in "project/test/". + +* Alternatively, check out this repo somewhere and use the `-d` parameter to +specify the path to the tests directory. + Usage ----- -Supposed to be added as a submodule like so: +* By default, all tests in the parent directory are run: - > cd my/project/test - > git submodule add https://github.com/egor-tensin/test-harness.git runner + ./test/runner/harness # Runs all tests in the test/ directory -This will add it as a submodule in `test/runner/` in your project's directory. +* You can filter tests to run using the `-f`/`--filter` parameter (uses +fnmatch(3)): -Run tests using the main.sh script: + ./test/runner/harness -f '*' # Runs all tests still + ./test/runner/harness -f '*label*' # Collects all test files containing "label" - > ./test/runner/main.sh +* Specify a directory to collect tests from using the `-d`/`--dir` parameter: -The script will discover all your tests in the parent directory, run them and -print a short summary. + ./harness -d path/to/tests/ API --- @@ -0,0 +1 @@ +src/main.sh
\ No newline at end of file @@ -9,18 +9,20 @@ set -o errexit -o nounset -o pipefail shopt -s inherit_errexit 2> /dev/null || true shopt -s lastpipe -_script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" -_script_dir="$( cd -- "$_script_dir" && pwd )" -readonly _script_dir _script_name="$( basename -- "${BASH_SOURCE[0]}" )" readonly _script_name +_script_path="$( realpath -e -- "${BASH_SOURCE[0]}" )" +readonly _script_path +_script_dir="$( dirname -- "$_script_path" )" +_script_dir="$( cd -- "$_script_dir" && pwd )" +readonly _script_dir -source "$_script_dir/lib/log.sh" +source "$_script_dir/log.sh" _test_run_file() { local test_file for test_file; do - source "$_script_dir/lib/test.sh" + source "$_script_dir/test.sh" local lib_file find "$tests_dir/lib" \ @@ -69,7 +71,7 @@ _test_usage() { } _test_parse_args() { - tests_dir="$_script_dir/.." + tests_dir="$_script_dir/../.." _test_pattern='*' while [ "$#" -gt 0 ]; do diff --git a/lib/test.sh b/src/test.sh index 7c5844b..7c5844b 100644 --- a/lib/test.sh +++ b/src/test.sh |
