tests: give few aclocal tests more significant names
[automake.git] / t / tap-log.sh
blobc679d4fea62a1ac2152725218cefeda5863fec15
1 #! /bin/sh
2 # Copyright (C) 2011-2012 Free Software Foundation, Inc.
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.
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.
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/>.
17 # TAP support:
18 # - log file creation
19 # - log file removal
20 # - stdout and stderr of a script go in its log file
21 # - TEST_SUITE_LOG redefinition, at either automake or make time
22 # - VERBOSE environment variable support
23 # Keep in sync with 'test-log.sh'.
25 . test-init.sh
27 cat > Makefile.am << 'END'
28 TESTS = pass.test skip.test xfail.test fail.test xpass.test error.test
29 TEST_SUITE_LOG = global.log
30 END
32 . tap-setup.sh
34 # Custom markers, for use in grepping checks.
35 cmarker=::: # comment marker
36 pmarker=%%% # plain maker
38 cat > pass.test <<END
39 #! /bin/sh -e
40 echo 1..1
41 echo "$pmarker pass $pmarker" >&2
42 echo "# $cmarker pass $cmarker" >&2
43 echo "ok 1"
44 END
46 cat > skip.test <<END
47 #! /bin/sh -e
48 echo 1..1
49 echo "$pmarker skip $pmarker"
50 echo "# $cmarker skip $cmarker"
51 echo "ok 1 # SKIP"
52 END
54 cat > xfail.test <<END
55 #! /bin/sh -e
56 echo 1..1
57 echo "$pmarker xfail $pmarker" >&2
58 echo "# $cmarker xfail $cmarker" >&2
59 echo "not ok 1 # TODO"
60 END
62 cat > fail.test <<END
63 #! /bin/sh -e
64 echo 1..1
65 echo "$pmarker fail $pmarker"
66 echo "# $cmarker fail $cmarker"
67 echo "not ok 1"
68 END
70 cat > xpass.test <<END
71 #! /bin/sh -e
72 echo 1..1
73 echo "$pmarker xpass $pmarker" >&2
74 echo "# $cmarker xpass $cmarker" >&2
75 echo "ok 1 # TODO"
76 END
78 cat > error.test <<END
79 #! /bin/sh -e
80 echo 1..1
81 echo "$pmarker error $pmarker"
82 echo "# $cmarker error $cmarker"
83 echo 'Bail out!'
84 END
86 chmod a+x *.test
88 TEST_SUITE_LOG=my.log $MAKE -e check && exit 1
89 ls -l # For debugging.
90 test ! -e test-suite.log
91 test ! -e global.log
92 test -f my.log
93 st=0
94 for result in pass fail xfail xpass skip error; do
95 cat $result.log # For debugging.
96 $FGREP "$pmarker $result $pmarker" $result.log || st=1
97 $FGREP "$cmarker $result $cmarker" $result.log || st=1
98 done
99 test $st -eq 0 || exit 1
100 cat my.log # For debugging.
101 for result in xfail fail xpass skip error; do
102 cat $result.log # For debugging.
103 $FGREP "$pmarker $result $pmarker" my.log || st=1
104 $FGREP "$cmarker $result $cmarker" my.log || st=1
105 done
106 test $($FGREP -c "$pmarker" my.log) -eq 5
107 test $($FGREP -c "$cmarker" my.log) -eq 5
109 # Passed test scripts shouldn't be mentioned in the global log.
110 $EGREP '(^pass|[^x]pass)\.test' my.log && exit 1
111 # But failing (expectedly or not) and skipped ones should.
112 $FGREP 'xfail.test' my.log
113 $FGREP 'skip.test' my.log
114 $FGREP 'fail.test' my.log
115 $FGREP 'xpass.test' my.log
116 $FGREP 'error.test' my.log
118 touch error2.log test-suite.log global.log
119 TEST_SUITE_LOG=my.log $MAKE -e mostlyclean
120 ls -l # For debugging.
121 test ! -e my.log
122 test ! -e pass.log
123 test ! -e fail.log
124 test ! -e xfail.log
125 test ! -e xpass.log
126 test ! -e skip.log
127 test ! -e error.log
128 # "make mostlyclean" shouldn't remove unrelated log files.
129 test -f error2.log
130 test -f test-suite.log
131 test -f global.log
133 rm -f *.log
135 VERBOSE=yes $MAKE check >stdout && { cat stdout; exit 1; }
136 cat stdout
137 cat global.log
138 test ! -e my.log
139 test ! -e test-suite.log
140 # Check that VERBOSE causes the global testsuite log to be
141 # emitted on stdout.
142 out=$(cat stdout)
143 log=$(cat global.log)
144 case $out in *"$log"*) ;; *) exit 1;; esac
146 touch error2.log test-suite.log my.log
147 $MAKE clean
148 ls -l # For debugging.
149 test ! -e global.log
150 test ! -e pass.log
151 test ! -e fail.log
152 test ! -e xfail.log
153 test ! -e xpass.log
154 test ! -e skip.log
155 test ! -e error.log
156 # "make clean" shouldn't remove unrelated log files.
157 test -f error2.log
158 test -f test-suite.log
159 test -f my.log
161 rm -f *.log