Merge branch 'yacc-quote-fix'
[automake.git] / tests / test-log.test
blob89d9ce8523c9e8de40865240d56770f0c02d86d4
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 # Check parallel-tests features:
18 # - log file creation
19 # - log file removal
20 # - stdout and stderr of a test 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 'tap-log.test'.
25 am_parallel_tests=yes
26 . ./defs || Exit 1
28 cat >> configure.in <<END
29 AC_OUTPUT
30 END
32 cat > Makefile.am << 'END'
33 TESTS = pass.test skip.test xfail.test fail.test xpass.test error.test
34 XFAIL_TESTS = xpass.test xfail.test
35 TEST_SUITE_LOG = global.log
36 END
38 # Custom markers, for use in grepping checks.
39 cmarker=::: # comment marker
40 pmarker=%%% # plain maker
42 cat > pass.test <<END
43 #! /bin/sh
44 echo "$pmarker pass $pmarker" >&2
45 echo "# $cmarker pass $cmarker" >&2
46 exit 0
47 END
49 cat > skip.test <<END
50 #! /bin/sh
51 echo "$pmarker skip $pmarker"
52 echo "# $cmarker skip $cmarker"
53 exit 77
54 END
56 cat > xfail.test <<END
57 #! /bin/sh
58 echo "$pmarker xfail $pmarker" >&2
59 echo "# $cmarker xfail $cmarker" >&2
60 exit 1
61 END
63 cat > fail.test <<END
64 #! /bin/sh
65 echo "$pmarker fail $pmarker"
66 echo "# $cmarker fail $cmarker"
67 exit 1
68 END
70 cat > xpass.test <<END
71 #! /bin/sh
72 echo "$pmarker xpass $pmarker" >&2
73 echo "# $cmarker xpass $cmarker" >&2
74 exit 0
75 END
77 cat > error.test <<END
78 #! /bin/sh
79 echo "$pmarker error $pmarker"
80 echo "# $cmarker error $cmarker"
81 exit 99
82 END
84 chmod a+x *.test
86 $ACLOCAL
87 $AUTOCONF
88 $AUTOMAKE -a
90 ./configure
92 TEST_SUITE_LOG=my.log $MAKE -e check && Exit 1
93 ls -l # For debugging.
94 test ! -f test-suite.log
95 test ! -f global.log
96 test -f my.log
97 st=0
98 for result in pass fail xfail xpass skip error; do
99 cat $result.log # For debugging.
100 $FGREP "$pmarker $result $pmarker" $result.log || st=1
101 $FGREP "$cmarker $result $cmarker" $result.log || st=1
102 done
103 test $st -eq 0 || Exit 1
104 cat my.log # For debugging.
105 for result in xfail fail xpass skip error; do
106 cat $result.log # For debugging.
107 $FGREP "$pmarker $result $pmarker" my.log || st=1
108 $FGREP "$cmarker $result $cmarker" my.log || st=1
109 done
110 test `$FGREP -c "$pmarker" my.log` -eq 5
111 test `$FGREP -c "$cmarker" my.log` -eq 5
113 have_rst_section ()
115 eqeq=`echo "$1" | sed 's/./=/g'`
116 # Assume $1 contains no RE metacharacters.
117 sed -n "/^$1$/,/^$eqeq$/p" $2 > got
118 (echo "$1" && echo "$eqeq") > exp
119 cat exp
120 cat got
121 diff exp got
124 # Passed test scripts shouldn't be mentioned in the global log.
125 $EGREP ':.*[^x]pass' my.log && Exit 1
126 # But failing (expectedly or not) and skipped ones should.
127 have_rst_section 'SKIP: skip' my.log
128 have_rst_section 'FAIL: fail' my.log
129 have_rst_section 'XFAIL: xfail' my.log
130 have_rst_section 'XPASS: xpass' my.log
131 have_rst_section 'ERROR: error' my.log
133 touch error2.log test-suite.log global.log
134 TEST_SUITE_LOG=my.log $MAKE -e mostlyclean
135 ls -l # For debugging.
136 test ! -f my.log
137 test ! -f pass.log
138 test ! -f fail.log
139 test ! -f xfail.log
140 test ! -f xpass.log
141 test ! -f skip.log
142 test ! -f error.log
143 # "make mostlyclean" shouldn't remove unrelated log files.
144 test -f error2.log
145 test -f test-suite.log
146 test -f global.log
148 rm -f *.log
150 VERBOSE=yes $MAKE check >stdout && { cat stdout; Exit 1; }
151 cat stdout
152 cat global.log
153 test ! -f my.log
154 test ! -f test-suite.log
155 # Check that VERBOSE causes the global testsuite log to be
156 # emitted on stdout.
157 out=`cat stdout`
158 log=`cat global.log`
159 case $out in *"$log"*) ;; *) Exit 1;; esac
161 touch error2.log test-suite.log my.log
162 $MAKE clean
163 ls -l # For debugging.
164 test ! -f global.log
165 test ! -f pass.log
166 test ! -f fail.log
167 test ! -f xfail.log
168 test ! -f xpass.log
169 test ! -f skip.log
170 test ! -f error.log
171 # "make clean" shouldn't remove unrelated log files.
172 test -f error2.log
173 test -f test-suite.log
174 test -f my.log
176 rm -f *.log