summaryrefslogtreecommitdiff
path: root/tests/test-metadata-recheck.test
blob: 0a7a7ccb42bf10d55d3a152ec072a3cde9667ae5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#! /bin/sh
# Copyright (C) 2011-2012 Free Software Foundation, Inc.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Test the "make recheck" semantics for custom test drivers, as documented
# in the Automake manual.

am_parallel_tests=yes
. ./defs || Exit 1

cat >> configure.ac << 'END'
AC_OUTPUT
END

cat > Makefile.am << 'END'
LOG_DRIVER = ./dummy-driver
TEST_EXTENSIONS =
TESTS =
END

#
# Tests to be re-run by "make recheck"
#

: > y-1
echo "foo bar" > y-2
echo ":recheck:" > y-3
echo ":recheck:yes" > y-4
echo ":recheck: who cares" > y-5
echo ":recheck: $tab   y" > y-6
echo ":recheck: yeah!$tab$tab " > y-7
cat > y-10 <<END
:foo:
:recheck: ???
END
cat > y-11 <<END
:recheck: YES
:foo:
END
cat > y-12 <<END
foo
:recheck:yes

bar
zardoz
END

echo "  $tab $tab$tab    :recheck: yes" > y-8

# The :test-result: fields and the fist line of the log should be
# irrelevant for the decision of whether "make recheck" should or
# should not re-run a test.

echo ":test-result: PASS" > y-100

echo "PASS: y-101"

cat > y-102 <<END
PASS: y-102
===========

:test-result: PASS
END

#
# Tests *not* to be re-run by "make recheck"
#

echo ":recheck:no" > n-1
echo ":recheck: no " > n-2
echo ":recheck: $tab   no" > n-3
echo ":recheck: no $tab$tab " > n-4
cat > n-5 <<END
:foo:
:recheck:no
END
cat > n-6 <<END
:recheck: no
:foo:
END
cat > n-7 <<END
foo
:recheck: no$tab$tab

bar
zardoz
END

echo "  $tab $tab$tab    :recheck: no" > n-8

# The :test-result: fields should be irrelevant for the decision of
# whether "make recheck" should or should not re-run a test.
cat > n-100 <<END
:test-result: FAIL
:test-result: XPASS
:test-result: ERROR
:test-result: UNKNOWN
:recheck: no
END

rechecked=`echo y-[0-9]*`

for t in [yn]-[0-9]*; do echo $t; done \
  | sed 's/.*/TESTS += &/' >> Makefile.am

cat Makefile.am # For debugging.

cat > dummy-driver <<'END'
#!/bin/sh
set -e; set -u
while test $# -gt 0; do
  case $1 in
    --log-file) log_file=$2; shift;;
    --trs-file) trs_file=$2; shift;;
    --test-name) test_name=$2; shift;;
    --expect-failure|--color-tests|--enable-hard-errors) shift;;
    --) shift; break;;
     *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
  esac
  shift
done
: > $test_name.run
: > $log_file
cp $1 $trs_file
END
chmod a+x dummy-driver

$ACLOCAL
$AUTOCONF
$AUTOMAKE

./configure

# The ':test-result:' fields should be ignored by "make recheck",
# but should cause the testsuite report to detect errors.
$MAKE check && Exit 1
ls -l
for t in $tests; do test -f $t.run; done
rm -f *.run

# But now the tests that actually get re-run have only ':test-result:'
# fields indicating success, so "make recheck" must pass.  Still, the
# next "make recheck" call should still re-run the same set of tests.
for iteration in 1 2; do
  $MAKE recheck
  ls -l
  for t in $rechecked; do test -f $t.run; done
  find . -name 'n-*.run' | grep . && Exit 1
  : For shells with busted 'set -e'.
done

: