-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dctest should exit 1 if any test fails. Change the final assertion in core.cljs to be a positive one: unless we see a :passed result, exit 1. This should make it more difficult to introduce this kind of bug while refactoring in the future. We didn't catch this regression in GHA, because we were swallowing all exit codes and only checking the results file counts. Move integration test running into ./test/runexamples, so we can test all examples locally more easily. Add exit code checking. Also support running all examples with nbb as well as with a built image.
- Loading branch information
Showing
4 changed files
with
93 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
#!/usr/bin/env bash | ||
|
||
PROJECT=${PROJECT:-${USER}} | ||
DCTEST_IMAGE=${DCTEST_IMAGE} | ||
|
||
repo_root=$(dirname $(readlink -f "${0}"))/.. | ||
examples_dir=${repo_root}/examples | ||
|
||
results_dir=$(mktemp -d) | ||
|
||
dc() { docker compose -p ${PROJECT} -f ${examples_dir}/docker-compose.yaml "${@}"; } | ||
up() { dc up -d; } | ||
down() { dc down; } | ||
|
||
fail() { | ||
msg=${1} | ||
down | ||
echo $msg | ||
exit 1 | ||
} | ||
|
||
check() { | ||
passed=${1}; shift | ||
failed=${1}; shift | ||
example_files=${@} | ||
|
||
if [ -z "${DCTEST_IMAGE}" ]; then | ||
cmd="${repo_root}/dctest --continue-on-error --results-file ${results_dir}/results.json ${PROJECT}" | ||
for example in ${example_files}; do | ||
cmd="${cmd} ${examples_dir}/${example}" | ||
done | ||
else | ||
cmd="docker run --rm -v /var/run/docker.sock:/var/run/docker.sock" | ||
cmd="${cmd} -v ${repo_root}/examples/:/app/examples -v ${results_dir}/:/app/results" | ||
cmd="${cmd} ${DCTEST_IMAGE} --continue-on-error --results-file /app/results/results.json ${PROJECT}" | ||
for example in ${example_files}; do | ||
cmd="${cmd} /app/examples/${example}" | ||
done | ||
fi | ||
|
||
echo "Running: ${cmd}" | ||
${cmd} | ||
exitcode=$? | ||
|
||
if [ "${failed}" == "0" ]; then | ||
expected_exitcode="0" | ||
else | ||
expected_exitcode="1" | ||
fi | ||
|
||
[ "${expected_exitcode}" == "${exitcode}" ] \ | ||
|| fail "Exit code ${exitcode} doesn't match expected ${expected_exitcode}" | ||
|
||
jq --exit-status '[.summary.passed == '${passed}', .summary.failed == '${failed}'] | all' ${results_dir}/results.json \ | ||
|| fail "Results file does not match expected passed/fail rate" | ||
|
||
node ${repo_root}/scripts/validateSchema.js ${results_dir}/results.json ${repo_root}/schemas/results-file.yaml \ | ||
|| fail "Results file does not match schema" | ||
} | ||
|
||
|
||
# TESTS | ||
|
||
up | ||
|
||
check 5 0 00-intro.yaml | ||
check 6 4 00-intro.yaml 01-fails.yaml | ||
check 12 0 02-deps.yaml | ||
|
||
down |