From ac61b36e069dd3daeca5d77257931a207b8d4545 Mon Sep 17 00:00:00 2001 From: Rajalakshmi Girish Date: Sun, 7 May 2023 00:06:31 -0700 Subject: [PATCH] Add an option to keep_going with run for modules on failure Signed-off-by: Rajalakshmi Girish --- scripts/test.sh | 7 +++++-- scripts/test_lib.sh | 16 +++++++++++++++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/scripts/test.sh b/scripts/test.sh index 9fd9d2c30..b8537e0a5 100755 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -26,6 +26,9 @@ # $ PASSES=unit PKG=./wal TESTCASE="\bTestNew\b" TIMEOUT=1m ./scripts/test.sh # $ PASSES=integration PKG=./client/integration TESTCASE="\bTestV2NoRetryEOF\b" TIMEOUT=1m ./scripts/test.sh # +# KEEP_GOING_SUITE must be set to true to keep going with the next suite execution, passed to PASSES variable when there is a failure +# in a particular suite. +# KEEP_GOING_MODULE must be set to true to keep going with execution when there is failure in any module. # # Run code coverage # COVERDIR must either be a absolute path or a relative path to the etcd root @@ -55,7 +58,7 @@ if [ -n "${OUTPUT_FILE}" ]; then fi PASSES=${PASSES:-"gofmt bom dep build unit"} -PASSES_CONTINUE=${PASSES_CONTINUE:-false} +KEEP_GOING_SUITE=${KEEP_GOING_SUITE:-false} PKG=${PKG:-} SHELLCHECK_VERSION=${SHELLCHECK_VERSION:-"v0.8.0"} @@ -651,7 +654,7 @@ function run_pass { return 0 else log_error "FAIL: '${pass}' FAILED at $(date)" - if [ "$PASSES_CONTINUE" = true ]; then + if [ "$KEEP_GOING_SUITE" = true ]; then return 2 else exit 255 diff --git a/scripts/test_lib.sh b/scripts/test_lib.sh index 336ed505a..e2464cd5e 100644 --- a/scripts/test_lib.sh +++ b/scripts/test_lib.sh @@ -203,11 +203,25 @@ function modules_exp() { # run given command across all modules and packages # (unless the set is limited using ${PKG} or / ${USERMOD}) function run_for_modules { + KEEP_GOING_MODULE=${KEEP_GOING_MODULE:-false} local pkg="${PKG:-./...}" + local fail_mod=false if [ -z "${USERMOD:-}" ]; then for m in $(module_dirs); do - run_for_module "${m}" "$@" "${pkg}" || return "$?" + if run_for_module "${m}" "$@" "${pkg}"; then + continue + else + if [ "$KEEP_GOING_MODULE" = false ]; then + log_error "There was a Failure in module ${m}, aborting..." + return 1 + fi + log_error "There was a Failure in module ${m}, keep going..." + fail_mod=true + fi done + if [ "$fail_mod" = true ]; then + return 1 + fi else run_for_module "${USERMOD}" "$@" "${pkg}" || return "$?" fi