Merge branch 'maint'
[platform/upstream/automake.git] / t / tap-recheck-logs.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2012 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 am_parallel_tests=yes
21 . ./defs || Exit 1
22
23 cat > Makefile.am << 'END'
24 TEST_LOG_COMPILER = cat
25 TESTS = foo.test bar.test baz.test
26 baz.log: zardoz
27 END
28
29 . "$am_testauxdir"/tap-setup.sh || fatal_ "sourcing tap-setup.sh"
30
31 : > zardoz
32
33 cat > foo.test <<'END'
34 1..2
35 ok 1
36 ok 2
37 END
38
39 cat > bar.test <<'END'
40 1..1
41 not ok 1
42 END
43
44 cat > baz.test <<'END'
45 1..1
46 Bail out!
47 END
48
49 # Even the tests that are not re-run should contribute to the testsuite
50 # summary when obtained by "make check RECHECK_LOGS=".
51 grep_summary ()
52 {
53   grep '^# TOTAL: *4$' stdout
54   grep '^# PASS: *2$' stdout
55   grep '^# XPASS: *0$' stdout
56   grep '^# FAIL: *1$' stdout
57   grep '^# XFAIL: *0$' stdout
58   grep '^# SKIP: *0$' stdout
59   grep '^# ERROR: *1$' stdout
60 }
61
62 $MAKE -e check && Exit 1
63 test -f foo.log
64 test -f bar.log
65 test -f baz.log
66
67 rm -f foo.log bar.log
68
69 env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
70 cat stdout
71 test -f foo.log
72 test -f bar.log
73 grep '^PASS: foo\.test 1$' stdout
74 grep '^PASS: foo\.test 2$' stdout
75 grep '^FAIL: bar\.test 1$' stdout
76 grep 'baz\.test' stdout && Exit 1
77 grep_summary
78
79 $sleep
80 touch foo.test
81 # We re-run only a successful test, but the tests that failed in the
82 # previous run should still be taken into account, and cause an overall
83 # failure.
84 env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
85 cat stdout
86 grep '^PASS: foo\.test 1$' stdout
87 grep '^PASS: foo\.test 2$' stdout
88 grep 'ba[rz]\.test' stdout && Exit 1
89 is_newest foo.log foo.test
90 grep_summary
91
92 $sleep
93 touch zardoz
94 env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
95 cat stdout
96 grep '^ERROR: baz\.test' stdout
97 $EGREP '(foo|bar)\.test' stdout && Exit 1
98 is_newest baz.log zardoz
99 grep_summary
100
101 # Now, explicitly retry with all test logs already updated, and ensure
102 # that the summary is still displayed.
103 env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
104 cat stdout
105 $EGREP '(foo|bar|baz)\.test' stdout && Exit 1
106 grep_summary
107
108 # The following should re-run foo.test (and only foo.test), even if its
109 # log file is up-to-date.
110 : > older
111 env RECHECK_LOGS=foo.log $MAKE -e check > stdout && { cat stdout; Exit 1; }
112 cat stdout
113 grep '^PASS: foo\.test 1$' stdout
114 grep '^PASS: foo\.test 2$' stdout
115 grep 'ba[rz]\.test' stdout && Exit 1
116 is_newest foo.log older
117 grep_summary
118
119 :