Merge pull request #15839 from Rajalakshmi-Girish/keep_going_module_testing2

Add an option to keep_going with run for modules on failure
This commit is contained in:
Benjamin Wang 2023-05-10 08:14:37 +08:00 committed by GitHub
commit 7f6d0d04ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 3 deletions

View File

@ -26,6 +26,9 @@
# $ PASSES=unit PKG=./wal TESTCASE="\bTestNew\b" TIMEOUT=1m ./scripts/test.sh # $ 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 # $ 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 # Run code coverage
# COVERDIR must either be a absolute path or a relative path to the etcd root # 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 fi
PASSES=${PASSES:-"gofmt bom dep build unit"} PASSES=${PASSES:-"gofmt bom dep build unit"}
PASSES_CONTINUE=${PASSES_CONTINUE:-false} KEEP_GOING_SUITE=${KEEP_GOING_SUITE:-false}
PKG=${PKG:-} PKG=${PKG:-}
SHELLCHECK_VERSION=${SHELLCHECK_VERSION:-"v0.8.0"} SHELLCHECK_VERSION=${SHELLCHECK_VERSION:-"v0.8.0"}
@ -651,7 +654,7 @@ function run_pass {
return 0 return 0
else else
log_error "FAIL: '${pass}' FAILED at $(date)" log_error "FAIL: '${pass}' FAILED at $(date)"
if [ "$PASSES_CONTINUE" = true ]; then if [ "$KEEP_GOING_SUITE" = true ]; then
return 2 return 2
else else
exit 255 exit 255

View File

@ -203,11 +203,25 @@ function modules_exp() {
# run given command across all modules and packages # run given command across all modules and packages
# (unless the set is limited using ${PKG} or / ${USERMOD}) # (unless the set is limited using ${PKG} or / ${USERMOD})
function run_for_modules { function run_for_modules {
KEEP_GOING_MODULE=${KEEP_GOING_MODULE:-false}
local pkg="${PKG:-./...}" local pkg="${PKG:-./...}"
local fail_mod=false
if [ -z "${USERMOD:-}" ]; then if [ -z "${USERMOD:-}" ]; then
for m in $(module_dirs); do 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 done
if [ "$fail_mod" = true ]; then
return 1
fi
else else
run_for_module "${USERMOD}" "$@" "${pkg}" || return "$?" run_for_module "${USERMOD}" "$@" "${pkg}" || return "$?"
fi fi