Debian Codegraph @

testing/tests/teardown.test

raw
1 # This test verifies the basic properties of teardowns: they get called after
2 # command regardess of their outcome, they receive TEST_FAILED and
3 # TEST_LAST_RETCODE environment variables, and they can fail otherwise
4 # successful tests.
5
6 # Succeeding tests: teardown runs
7 # %TEST-EXEC: btest -t tests/success
8
9 # Failing test: teardown runs, run fails
10 # %TEST-EXEC-FAIL: btest -t tests/failure
11
12 # Succeeding test: teardown introduces failure, run fails
13 # %TEST-EXEC-FAIL: btest -c btest.failing-teardown.cfg -t tests/success
14
15 # %TEST-EXEC: btest-diff output
16
17 %TEST-START-FILE btest.cfg
18 [btest]
19 TestDirs = tests
20 TmpDir = .tmp
21 BaselineDir = Baseline
22 Teardown = echo "Teardown $TEST_NAME $TEST_FAILED $TEST_LAST_RETCODE" >>../../output
23 %TEST-END-FILE
24
25 %TEST-START-FILE btest.failing-teardown.cfg
26 [btest]
27 TestDirs = tests
28 TmpDir = .tmp
29 BaselineDir = Baseline
30 Teardown = echo "Teardown $TEST_NAME $TEST_FAILED $TEST_LAST_RETCODE (failing now)" >>../../output && false
31 %TEST-END-FILE
32
33 # %TEST-START-FILE tests/success
34 @TEST-EXEC: echo "success" >>../../output
35 # %TEST-END-FILE
36
37 # %TEST-START-FILE tests/failure
38 @TEST-EXEC: echo "success" >>../../output
39 @TEST-EXEC: echo "failure" >>../../output && exit 42
40 @TEST-EXEC: echo "not reached" >>../../output
41 # %TEST-END-FILE