release: stable micro release 1.13.2
[automake.git] / t / test-metadata-global-result.sh
blob26193c88f40bffdf3029f1a7ec4648f1cdbbb3e0
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 # Parallel testsuite harness: check APIs for the registering the
18 # "global test result" in '*.trs' files, as documented in the automake
19 # manual.
21 . test-init.sh
23 cat >> configure.ac << 'END'
24 AC_OUTPUT
25 END
27 cat > Makefile.am << 'END'
28 TEST_EXTENSIONS = .test .x
29 TEST_LOG_DRIVER = ./dummy-driver
30 X_LOG_DRIVER = ./dummy-driver
31 TESTS = foo.test zar-doz.test
32 END
34 cat > dummy-driver <<'END'
35 #! /bin/sh
36 set -e; set -u
37 while test $# -gt 0; do
38 case $1 in
39 --log-file) log_file=$2; shift;;
40 --trs-file) trs_file=$2; shift;;
41 --test-name) test_name=$2; shift;;
42 --expect-failure|--color-tests|--enable-hard-errors) shift;;
43 --) shift; break;;
44 *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
45 esac
46 shift
47 done
48 echo logloglog > $log_file
49 cp $1 $trs_file
50 END
51 chmod a+x dummy-driver
53 # Do this in a subroutine to avoid quoting problem in the backticked
54 # command substitution below.
55 get_escaped_line()
57 sed -e 's,[$^/\\\.],\\&,g' -e 1q "$@"
60 have_result ()
62 cat > exp; echo >> exp; echo logloglog >> exp
63 eline=$(get_escaped_line exp)
64 sed -n -e "/^$eline$/,/^logloglog$/p" test-suite.log > got
65 cat exp; cat got
66 diff exp got
69 $ACLOCAL
70 $AUTOCONF
71 $AUTOMAKE
73 ./configure
75 : Basic checks.
77 echo :global-test-result: PASS > foo.test
78 echo :global-test-result: ERROR > zar-doz.x
80 $MAKE check
81 cat test-suite.log
83 have_result <<END
84 PASS: foo
85 =========
86 END
88 have_result <<END
89 ERROR: zar-doz
90 ==============
91 END
93 : Try usage documented in the manual.
95 echo :global-test-result: PASS/SKIP > foo.test
96 echo :global-test-result: ALMOST PASSED > zar-doz.x
98 $MAKE check
99 cat test-suite.log
101 have_result <<END
102 PASS/SKIP: foo
103 ==============
106 have_result <<END
107 ALMOST PASSED: zar-doz
108 ======================
111 : Fields ':test-result:' does not interfere with the global test result.
113 cat > foo.test << 'END'
114 :test-result: FAIL
115 :global-test-result: PASS
116 :test-result: ERROR
119 cat > zar-doz.x << 'END'
120 :global-test-result: FAIL
121 :test-result: SKIP
122 :test-result: XFAIL
125 $MAKE check && exit 1
126 cat test-suite.log
128 have_result <<END
129 PASS: foo
130 =========
133 have_result <<END
134 FAIL: zar-doz
135 =============
138 : What happens when ':global-test-result:' is absent.
140 cat > foo.test << 'END'
141 :test-result: PASS
142 :test-result: ERROR
144 : > zar-doz.x
146 $MAKE check && exit 1
147 cat test-suite.log
149 have_result <<END
150 RUN: foo
151 ========
154 have_result <<END
155 RUN: zar-doz
156 ============
159 # Leading and trailing whitespace gets eaten/normalized.
161 echo ":global-test-result:SKIP${tab} ${tab}${tab}" > foo.test
162 echo ":global-test-result:${tab} ${tab}XFAIL ${tab} " > zar-doz.x
164 $MAKE check
165 cat test-suite.log
167 have_result <<END
168 SKIP: foo
169 =========
172 have_result <<END
173 XFAIL: zar-doz
174 ==============
177 # Whitespaces before and after ':global-test-result:' are handled OK.
179 echo " $tab:global-test-result:PASS" > foo.test
180 echo "${tab}${tab}:global-test-result:${tab} ${tab}SKIP" > zar-doz.x
182 $MAKE check
183 cat test-suite.log
185 have_result <<END
186 PASS: foo
187 =========
190 have_result <<END
191 SKIP: zar-doz
192 =============