From a91198bd3c9b161334e80ca53f5ad02d09bb1169 Mon Sep 17 00:00:00 2001 From: Philipp Wollermann Date: Mon, 14 Dec 2015 14:21:40 +0000 Subject: Add unit tests for the new errexit feature in unittest.bash. -- MOS_MIGRATED_REVID=110148583 --- src/test/shell/unittest_test.sh | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) (limited to 'src/test/shell') diff --git a/src/test/shell/unittest_test.sh b/src/test/shell/unittest_test.sh index 0a2864fc7a..9cbb8f36dc 100755 --- a/src/test/shell/unittest_test.sh +++ b/src/test/shell/unittest_test.sh @@ -59,7 +59,7 @@ function test_thing() { run_suite "thing tests" EOF chmod +x thing.sh - ./thing.sh &> $TEST_log || echo "thing.sh should fail" + ./thing.sh &> $TEST_log && fail "thing.sh should fail" expect_not_log "__fail: No such file or directory" assert_contains "I'm a failure." $XML_OUTPUT_FILE } @@ -77,9 +77,39 @@ function test_thing() { run_suite "thing tests" EOF chmod +x thing.sh - ./thing.sh &> $TEST_log || echo "thing.sh should fail" + ./thing.sh &> $TEST_log && fail "thing.sh should fail" expect_not_log "__fail: No such file or directory" assert_contains "No failure message" $XML_OUTPUT_FILE } +function test_errexit_prints_stack_trace() { + cd $TEST_TMPDIR + cat > thing.sh < $TEST_log && fail "thing.sh should fail" + #cat $TEST_log + + # Make sure the full stack trace is there. + expect_log "test_thing FAILED: terminated because this command returned a non-zero status:" + expect_log "./thing.sh:[0-9]*: in call to helper" + expect_log "./thing.sh:[0-9]*: in call to test_thing" +} + run_suite "unittests Tests" -- cgit v1.2.3