tests: remove recipes that run tests with 'prove'
[platform/upstream/automake.git] / tests / test-metadata-global-log.test
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 # Custom test drivers and parallel-tests harness: check the documented
18 # semantics for deciding when the content of a test log file should be
19 # copied in the global test-suite.log file.  Currently, this is done
20 # with the use of the reStructuredText field ':copy-in-global-log:' in
21 # the associated '.trs' files.
22
23 am_parallel_tests=yes
24 . ./defs || Exit 1
25
26 cat >> configure.ac << 'END'
27 AC_OUTPUT
28 END
29
30 cat > Makefile.am << 'END'
31 TEST_LOG_DRIVER = ./passthrough-driver
32 TEST_LOG_COMPILER = $(SHELL) -e
33 END
34
35 cat > passthrough-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 "$test_name: RUN"
50 "$@" >$log_file 2>&1 5>$trs_file
51 END
52 chmod a+x passthrough-driver
53
54 # The ':test-result:' and ':recheck:' fields and the first line of the
55 # log file should be be irrelevant for the decision of whether a test
56 # output is to be copied in the 'test-suite.log'.
57
58 cat > no-1.test <<END
59 echo :test-result: SKIP >&5
60 echo :copy-in-global-log: no >&5
61 echo :test-result: FAIL >&5
62 echo :test-result: XPASS >&5
63 echo not seen 1
64 END
65
66 # In the last line, with leading and trailing whitespace in the value.
67 cat > no-2.test <<END
68 echo ":test-result: FAIL" >&5
69 echo "not seen 2"
70 echo ":recheck: yes" >&5
71 echo ":copy-in-global-log:$tab $tab no   $tab" >&5
72 END
73
74 for RES in XPASS FAIL XFAIL SKIP ERROR UNKNOWN; do
75   unindent > $RES.test <<END
76     echo :test-result: $RES >&5
77     echo :copy-in-global-log: no >&5
78     echo not seen $RES
79 END
80 done
81
82 # In the first line, with no whitespace.
83 cat > no-3.test <<END
84 echo :copy-in-global-log:no >&5
85 echo ":test-result: FAIL" >&5
86 echo "not seen 3"
87 END
88
89 # Leading whitespace before the field.
90 cat > no-4.test <<END
91 echo ":test-result: FAIL" >&5
92 echo "  $tab $tab$tab   :copy-in-global-log: no" >&5
93 echo "not seen 4"
94 END
95
96 cat > yes-1.test <<END
97 echo :test-result: PASS >&5
98 echo :copy-in-global-log: yes >&5
99 echo seen yes 1
100 END
101
102 # A lacking ':copy-in-global-log:' implies that the content of
103 # the log file should be copied.
104 cat > yes-2.test <<END
105 echo :test-result: PASS >&5
106 echo seen yes 2
107 END
108
109 # Three corner cases.
110
111 cat > corn-1.test <<END
112 echo seen corn 1
113 echo ':copy-in-global-log:' >&5
114 END
115
116 cat > corn-2.test <<END
117 echo seen corn 2
118 echo '$tab $tab$tab' >&5
119 END
120
121 cat > corn-3.test <<'END'
122 echo seen corn 31
123 echo ':copy-in-global-log:#@%!' >&5
124 echo seen corn 32
125 END
126
127 echo TESTS = *.test >> Makefile.am
128
129 $ACLOCAL
130 $AUTOCONF
131 $AUTOMAKE
132
133 ./configure
134
135 # We don't care about the exit status of "make check" here, that
136 # should be checked in other tests.
137 $MAKE check || :
138 cat test-suite.log
139 grep '^seen yes 1$' test-suite.log
140 grep '^seen yes 2$' test-suite.log
141 grep '^seen corn 1$' test-suite.log
142 grep '^seen corn 2$' test-suite.log
143 grep '^seen corn 31$' test-suite.log
144 grep '^seen corn 32$' test-suite.log
145 $FGREP 'not seen' test-suite.log && Exit 1
146
147 :