Skip to content

Commit

Permalink
Merge pull request etcd-io#15839 from Rajalakshmi-Girish/keep_going_m…
Browse files Browse the repository at this point in the history
…odule_testing2

Add an option to keep_going with run for modules on failure
  • Loading branch information
ahrtr authored May 10, 2023
2 parents b404d25 + ac61b36 commit 7f6d0d0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 5 additions & 2 deletions scripts/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"}

Expand Down Expand Up @@ -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
Expand Down
16 changes: 15 additions & 1 deletion scripts/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7f6d0d0

Please sign in to comment.