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)
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/>.
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'.
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
34 # Custom markers, for use in grepping checks.
35 cmarker
=::: # comment marker
36 pmarker
=%%% # plain maker
41 echo "$pmarker pass $pmarker" >&2
42 echo "# $cmarker pass $cmarker" >&2
49 echo "$pmarker skip $pmarker"
50 echo "# $cmarker skip $cmarker"
54 cat > xfail.
test <<END
57 echo "$pmarker xfail $pmarker" >&2
58 echo "# $cmarker xfail $cmarker" >&2
59 echo "not ok 1 # TODO"
65 echo "$pmarker fail $pmarker"
66 echo "# $cmarker fail $cmarker"
70 cat > xpass.
test <<END
73 echo "$pmarker xpass $pmarker" >&2
74 echo "# $cmarker xpass $cmarker" >&2
78 cat > error.
test <<END
81 echo "$pmarker error $pmarker"
82 echo "# $cmarker error $cmarker"
88 TEST_SUITE_LOG
=my.log
$MAKE -e check
&& exit 1
89 ls -l # For debugging.
90 test ! -e test-suite.log
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
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
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.
128 # "make mostlyclean" shouldn't remove unrelated log files.
130 test -f test-suite.log
135 VERBOSE
=yes $MAKE check
>stdout
&& { cat stdout
; exit 1; }
139 test ! -e test-suite.log
140 # Check that VERBOSE causes the global testsuite log to be
143 log
=$
(cat global.log
)
144 case $out in *"$log"*) ;; *) exit 1;; esac
146 touch error2.log test-suite.log my.log
148 ls -l # For debugging.
156 # "make clean" shouldn't remove unrelated log files.
158 test -f test-suite.log