tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / tap-recheck-logs.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # TAP support:
18 # - RECHECK_LOGS
19
20 . test-init.sh
21
22 cat > Makefile.am << 'END'
23 TEST_LOG_COMPILER = cat
24 TESTS = foo.test bar.test baz.test
25 baz.log: zardoz
26 END
27
28 . tap-setup.sh
29
30 : > zardoz
31
32 cat > foo.test <<'END'
33 1..2
34 ok 1
35 ok 2
36 END
37
38 cat > bar.test <<'END'
39 1..1
40 not ok 1
41 END
42
43 cat > baz.test <<'END'
44 1..1
45 Bail out!
46 END
47
48 # Even the tests that are not re-run should contribute to the testsuite
49 # summary when obtained by "make check RECHECK_LOGS=".
50 grep_summary ()
51 {
52   grep '^# TOTAL: *4$' stdout
53   grep '^# PASS: *2$' stdout
54   grep '^# XPASS: *0$' stdout
55   grep '^# FAIL: *1$' stdout
56   grep '^# XFAIL: *0$' stdout
57   grep '^# SKIP: *0$' stdout
58   grep '^# ERROR: *1$' stdout
59 }
60
61 run_make -e FAIL check
62 test -f foo.log
63 test -f bar.log
64 test -f baz.log
65
66 rm -f foo.log bar.log
67
68 run_make -O -e FAIL check RECHECK_LOGS=
69 test -f foo.log
70 test -f bar.log
71 grep '^PASS: foo\.test 1$' stdout
72 grep '^PASS: foo\.test 2$' stdout
73 grep '^FAIL: bar\.test 1$' stdout
74 grep 'baz\.test' stdout && exit 1
75 grep_summary
76
77 $sleep
78 touch foo.test
79 # We re-run only a successful test, but the tests that failed in the
80 # previous run should still be taken into account, and cause an overall
81 # failure.
82 run_make -O -e FAIL check RECHECK_LOGS=
83 grep '^PASS: foo\.test 1$' stdout
84 grep '^PASS: foo\.test 2$' stdout
85 grep 'ba[rz]\.test' stdout && exit 1
86 is_newest foo.log foo.test
87 grep_summary
88
89 $sleep
90 touch zardoz
91 run_make -O -e FAIL check RECHECK_LOGS=
92 grep '^ERROR: baz\.test' stdout
93 $EGREP '(foo|bar)\.test' stdout && exit 1
94 is_newest baz.log zardoz
95 grep_summary
96
97 # Now, explicitly retry with all test logs already updated, and ensure
98 # that the summary is still displayed.
99 run_make -O -e FAIL check RECHECK_LOGS=
100 $EGREP '(foo|bar|baz)\.test' stdout && exit 1
101 grep_summary
102
103 # The following should re-run foo.test (and only foo.test), even if its
104 # log file is up-to-date.
105 : > older
106 run_make -O -e FAIL check RECHECK_LOGS=foo.log
107 grep '^PASS: foo\.test 1$' stdout
108 grep '^PASS: foo\.test 2$' stdout
109 grep 'ba[rz]\.test' stdout && exit 1
110 is_newest foo.log older
111 grep_summary
112
113 :