Merge branch 'rmch'
[platform/upstream/automake.git] / t / test-metadata-global-result.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 # Parallel testsuite harness: check APIs for the registering the
18 # "global test result" in '*.trs' files, as documented in the automake
19 # manual.
20
21 am_parallel_tests=yes
22 . ./defs || Exit 1
23
24 cat >> configure.ac << 'END'
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am << 'END'
29 TEST_EXTENSIONS = .test .x
30 TEST_LOG_DRIVER = ./dummy-driver
31 X_LOG_DRIVER = ./dummy-driver
32 TESTS = foo.test zar-doz.test
33 END
34
35 cat > dummy-driver <<'END'
36 #! /bin/sh
37 set -e; set -u
38 while test $# -gt 0; do
39   case $1 in
40     --log-file) log_file=$2; shift;;
41     --trs-file) trs_file=$2; shift;;
42     --test-name) test_name=$2; shift;;
43     --expect-failure|--color-tests|--enable-hard-errors) shift;;
44     --) shift; break;;
45      *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
46   esac
47   shift
48 done
49 echo logloglog > $log_file
50 cp $1 $trs_file
51 END
52 chmod a+x dummy-driver
53
54 # Do this in a subroutine to avoid quoting problem in the backticked
55 # command substitution below.
56 get_escaped_line()
57 {
58    sed -e 's,[$^/\\\.],\\&,g' -e 1q "$@"
59 }
60
61 have_result ()
62 {
63    cat > exp; echo >> exp; echo logloglog >> exp
64    eline=`get_escaped_line exp`
65    sed -n -e "/^$eline$/,/^logloglog$/p" test-suite.log > got
66    cat exp; cat got
67    diff exp got
68 }
69
70 $ACLOCAL
71 $AUTOCONF
72 $AUTOMAKE
73
74 ./configure
75
76 : Basic checks.
77
78 echo :global-test-result: PASS > foo.test
79 echo :global-test-result: ERROR > zar-doz.x
80
81 $MAKE check
82 cat test-suite.log
83
84 have_result <<END
85 PASS: foo
86 =========
87 END
88
89 have_result <<END
90 ERROR: zar-doz
91 ==============
92 END
93
94 : Try usage documented in the manual.
95
96 echo :global-test-result: PASS/SKIP > foo.test
97 echo :global-test-result: ALMOST PASSED > zar-doz.x
98
99 $MAKE check
100 cat test-suite.log
101
102 have_result <<END
103 PASS/SKIP: foo
104 ==============
105 END
106
107 have_result <<END
108 ALMOST PASSED: zar-doz
109 ======================
110 END
111
112 : Fields ':test-result:' does not interfere with the global test result.
113
114 cat > foo.test << 'END'
115 :test-result: FAIL
116 :global-test-result: PASS
117 :test-result: ERROR
118 END
119
120 cat > zar-doz.x << 'END'
121 :global-test-result: FAIL
122 :test-result: SKIP
123 :test-result: XFAIL
124 END
125
126 $MAKE check && Exit 1
127 cat test-suite.log
128
129 have_result <<END
130 PASS: foo
131 =========
132 END
133
134 have_result <<END
135 FAIL: zar-doz
136 =============
137 END
138
139 : What happens when ':global-test-result:' is absent.
140
141 cat > foo.test << 'END'
142 :test-result: PASS
143 :test-result: ERROR
144 END
145 : > zar-doz.x
146
147 $MAKE check && Exit 1
148 cat test-suite.log
149
150 have_result <<END
151 RUN: foo
152 ========
153 END
154
155 have_result <<END
156 RUN: zar-doz
157 ============
158 END
159
160 # Leading and trailing whitespace gets eaten/normalized.
161
162 echo ":global-test-result:SKIP${tab}   ${tab}${tab}" > foo.test
163 echo ":global-test-result:${tab}   ${tab}XFAIL  ${tab}   " > zar-doz.x
164
165 $MAKE check
166 cat test-suite.log
167
168 have_result <<END
169 SKIP: foo
170 =========
171 END
172
173 have_result <<END
174 XFAIL: zar-doz
175 ==============
176 END
177
178 # Whitespaces before and after ':global-test-result:' are handled OK.
179
180 echo "   $tab:global-test-result:PASS" > foo.test
181 echo "${tab}${tab}:global-test-result:${tab}   ${tab}SKIP" > zar-doz.x
182
183 $MAKE check
184 cat test-suite.log
185
186 have_result <<END
187 PASS: foo
188 =========
189 END
190
191 have_result <<END
192 SKIP: zar-doz
193 =============
194 END
195
196 :