BUG: test_todo_session with error exit doesn't work
BUG 1: didn't report non-error exit A test that enforces a non-zero exit code via "=== N" would succeed when the command under test returned with success (0); only differing exit codes would be correctly reported. Corrected logic so that the check for the exit code would always run, not just when the command under test failed. BUG 2: too early evaluation of $? In the test expression, the evaluation of $? must be deferred until the test expression itself is evaluated. Escaping $? to prevent premature evaluation in the context of the expression definition.
This commit is contained in:
@@ -542,7 +542,7 @@ test_todo_session () {
|
||||
if [ $status = 0 ]; then
|
||||
test_expect_success "$1 $subnum" "$cmd > output && test_cmp expect output"
|
||||
else
|
||||
test_expect_success "$1 $subnum" "$cmd > output || test $? = $status && test_cmp expect output"
|
||||
test_expect_success "$1 $subnum" "$cmd > output ; test \$? = $status && test_cmp expect output"
|
||||
fi
|
||||
|
||||
subnum=$(($subnum + 1))
|
||||
@@ -560,7 +560,7 @@ test_todo_session () {
|
||||
if [ $status = 0 ]; then
|
||||
test_expect_success "$1 $subnum" "$cmd > output && test_cmp expect output"
|
||||
else
|
||||
test_expect_success "$1 $subnum" "$cmd > output || test $? = $status && test_cmp expect output"
|
||||
test_expect_success "$1 $subnum" "$cmd > output ; test \$? = $status && test_cmp expect output"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user