You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that set -e does not cause the script to abort if a test fails. For example if the script was (with both set -e and the typo fixed)
#!/bin/sh
test_description="A trival test that should fail"
. lib/test-lib.sh
set -e
test_expect_success "false" 'false'
test_expect_success "true" 'true'
test_done
the output will be:
not ok 1 - false
# false
ok 2 - true
# failed 1 among 2 test(s)
1..2
mmm, i see. set -e doesnt apply like i thought it would because the test_expect_success commands are essentially running a subshell by calling eval and actually not returning a non-zero value even on test failure
Without it simple typos may be hard to catch. For example, this trivial test script should fail:
But it doesn't because I misspelled
successs
. Instead here is the output:It shows the error, but in a large script with lots of tests it may be very easy to miss.
If the
set -e
in uncommented than the script will abort and make the typo more obvious:I am not sure what consequences using
set -e
globally will have though.The text was updated successfully, but these errors were encountered: