fix: use PIPESTATUS to capture correct exit code in collect()#9
Open
mobs75 wants to merge 1 commit into
Open
Conversation
The collect() function used 'if "$@" 2>&1 | tee _log', which captures
the exit status of 'tee' (always 0) instead of the tested script, due
to how bash pipelines report $?. This caused every failing test to be
recorded as SUCCESS in the final summary, regardless of its actual
exit code.
Confirmed with 11-sys-spark.sh: the script exits 1 explicitly after
'FAIL: Spark master not ready', but was still reported as
'SUCCESS ./11-sys-spark.sh' in the summary before this fix.
Fixed by checking ${PIPESTATUS[0]} instead of the pipeline's own
exit code.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
collect()function intests/all.shused:This captures the exit status of
tee(always 0) instead of the tested script's own exit code, because bash pipelines report$?from the last command in the pipe.As a result, every test script that fails with a non-zero exit code was still recorded as SUCCESS in
_resultsand in the final summary.Confirmed on a kind cluster: after this fix,
5-sys-seaweedfs.shand11-sso-mock.sh, which fail with a real error, are now correctly reported as FAIL instead of SUCCESS. The overalltask testrun now also exits non-zero when a test genuinely fails, instead of always reporting success.Fix: check
${PIPESTATUS[0]}(the exit code of the first command in the pipeline) instead of the pipeline's own exit status.