diff --git a/.changeset/cyan-rabbits-double.md b/.changeset/cyan-rabbits-double.md new file mode 100644 index 0000000..92c0651 --- /dev/null +++ b/.changeset/cyan-rabbits-double.md @@ -0,0 +1,5 @@ +--- +"@zazuko/shacl-test": patch +--- + +Provide test run summary and exit with nonzero code when no tests are found diff --git a/README.md b/README.md index 362a234..bd833dd 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,9 @@ npx shacl-test \ --command="${COMMAND}" ``` -Only the `--shapes` option is required. The rest are optional. +The `--shapes` option is required. +Also, you must provide at least `--valid-cases` or `--invalid-cases`, lest no tests are run. +The rest are optional. `--shapes` can be a filesystem path or URL and include [`code:imports`](https://github.com/zazuko/rdf-transform-graph-imports). diff --git a/run.sh b/run.sh index 10505e9..986a54a 100755 --- a/run.sh +++ b/run.sh @@ -66,8 +66,12 @@ loadFullShape() { "$SCRIPT_PATH"/load-graph.js "$1" | "$SCRIPT_PATH"/pretty-print.js --prefixes "${prefixes[@]}" } +testsRun=0 + # iterate over valid cases, run validation and monitor exit code for file in $validCases; do + testsRun=$((testsRun + 1)) + name=$(basename "$file") relativePath=$(node -e "console.log(require('path').relative('$WORKING_DIR', '$file'))") @@ -92,6 +96,8 @@ done # iterate over invalid cases for file in $invalidCases; do + testsRun=$((testsRun + 1)) + name=$(basename "$file") relativePath=$(node -e "console.log(require('path').relative('$WORKING_DIR', '$file'))") @@ -116,4 +122,17 @@ for file in $invalidCases; do fi done +if [ $testsRun -eq 0 ]; then + echo "ℹī¸ No test cases found" + echo "ℹī¸ Check if the --valid-cases and --invalid-cases globs match any files" + exit 255 +fi + +echo "🏁 Tests cases run: $testsRun" +if [ $FAILED -eq 0 ]; then + echo "🎉 All tests passed" +else + echo "❌ Failed $FAILED tests" +fi + exit $FAILED