From 7790594ee4f92231cd37f8ce0a662bebd8700985 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Mon, 3 Feb 2020 14:32:48 -0500 Subject: [PATCH] entrypoint: fix pausing after test failure The --pause option for the entrypoint script is useful for interactive debugging after a test failure, but the script was not pausing if the test suite failed. Add code to explicitly handle test failures including pausing. Signed-off-by: John Mulligan --- entrypoint.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/entrypoint.sh b/entrypoint.sh index f5609d1..8499f03 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -51,6 +51,13 @@ while true ; do esac done +test_failed() { + local pkg="$1" + echo "*** ERROR: ${pkg} tests failed" + pause_if_needed + return 1 +} + test_pkg() { local pkg="$1" if [[ "$TEST_PKG" && "$TEST_PKG" != "$pkg" ]]; then @@ -67,7 +74,9 @@ test_pkg() { fi go test -v "${testargs[@]}" "./$pkg" + ret=$? grep -v "^mode: count" "$pkg.cover.out" >> "cover.out" + return ${ret} } pre_all_tests() { @@ -105,13 +114,14 @@ test_go_ceph() { ) pre_all_tests for pkg in "${pkgs[@]}"; do - test_pkg "$pkg" + test_pkg "$pkg" || test_failed "$pkg" done post_all_tests } pause_if_needed() { if [[ ${PAUSE} = yes ]]; then + echo "*** pausing execution" sleep infinity fi }