Merge branch 'msvc' into maint
[platform/upstream/automake.git] / tests / parallel-tests.test
1 #! /bin/sh
2 # Copyright (C) 2009, 2010  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 # Check parallel-tests features:
18 # - VERBOSE
19 # - clean
20 # - TEST_SUITE_LOG
21 # - dependencies between tests
22 # - TESTS
23 # - TEST_LOGS
24 # - RECHECK_LOGS
25
26 parallel_tests=yes
27 . ./defs || Exit 1
28
29 set -e
30
31 cat >> configure.in << 'END'
32 AC_OUTPUT
33 END
34
35 cat > Makefile.am << 'END'
36 TEST_SUITE_LOG = mylog.log
37 TESTS = foo.test bar.test baz.test
38 XFAIL_TESTS = bar.test
39 foo.log: bar.log
40 bar.log: baz.log
41 END
42
43 # foo.test and bar.test sleep to ensure their logs are always strictly newer
44 # than the logs of their prerequisites, for HP-UX make.  The quoting pleases
45 # maintainer-check.
46 cat >>foo.test <<'END'
47 #! /bin/sh
48 echo "this is $0"
49 sleep '1'
50 exit 0
51 END
52 cat >>bar.test <<'END'
53 #! /bin/sh
54 echo "this is $0"
55 sleep '1'
56 exit 99
57 END
58 cat >>baz.test <<'END'
59 #! /bin/sh
60 echo "this is $0"
61 exit 1
62 END
63 chmod a+x foo.test bar.test baz.test
64
65 $ACLOCAL
66 $AUTOCONF
67 $AUTOMAKE -a
68
69 ./configure
70
71 $MAKE check >stdout && { cat stdout; Exit 1; }
72 cat stdout
73 # There should be two errors: bar.test is a hard error.
74 test `grep -c '^FAIL' stdout` -eq 2
75 test -f mylog.log
76 test `grep -c '^FAIL' mylog.log` -eq 2
77 test -f baz.log
78 test -f bar.log
79 test -f foo.log
80 # The summary should be formatted correctly.
81 grep 'failedn' stdout && Exit 1
82
83 # clean should remove all log files (but not more).
84 : > unrelated.log
85 $MAKE clean
86 test ! -f baz.log
87 test ! -f bar.log
88 test ! -f foo.log
89 test ! -f mylog.log
90 test -f unrelated.log
91
92 # Check dependencies: baz.test needs to run before bar.test,
93 # but foo.test is not needed.
94 # Note that this usage has a problem: the summary will only
95 # take bar.log into account, because the $(TEST_SUITE_LOG) rule
96 # does not "see" baz.log.  Hmm.
97 env TESTS='bar.test' $MAKE -e check && Exit 1
98 test -f baz.log
99 test -f bar.log
100 test ! -f foo.log
101 test -f mylog.log
102
103 # Upon a lazy rerun, foo.test should be run, but the others shouldn't.
104 # Note that the lazy rerun still exits with a failure, due to the previous
105 # test failures.
106 # Note that the previous test and this one taken together expose the timing
107 # issue that requires the check-TESTS rule to always remove TEST_SUITE_LOG
108 # before running the tests lazily.
109 env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
110 cat stdout
111 test -f foo.log
112 grep foo.test stdout
113 grep bar.test stdout && Exit 1
114 grep baz.test stdout && Exit 1
115 grep '2.*tests.*failed' stdout
116
117 # Now, explicitly retry with all test logs already updated, and ensure
118 # that the summary is still displayed.
119 env RECHECK_LOGS= $MAKE -e check > stdout && { cat stdout; Exit 1; }
120 cat stdout
121 grep foo.test stdout && Exit 1
122 grep bar.test stdout && Exit 1
123 grep baz.test stdout && Exit 1
124 grep '2.*tests.*failed' stdout
125
126 # Lazily rerunning only foo should only rerun this one test.
127 env RECHECK_LOGS=foo.log $MAKE -e check > stdout && { cat stdout; Exit 1; }
128 cat stdout
129 grep foo.test stdout
130 grep bar.test stdout && Exit 1
131 grep baz.test stdout && Exit 1
132 grep '2.*tests.*failed' stdout
133
134 # Test VERBOSE.
135 env VERBOSE=yes $MAKE -e check > stdout && { cat stdout; Exit 1; }
136 cat stdout
137 grep 'this is.*bar.test' stdout
138 grep 'this is.*baz.test' stdout
139
140 $MAKE clean
141 env TEST_LOGS=baz.log $MAKE -e check > stdout && { cat stdout; Exit 1; }
142 cat stdout
143 grep foo.test stdout && Exit 1
144 grep bar.test stdout && Exit 1
145 grep baz.test stdout
146
147 $MAKE clean
148 env TESTS=baz.test $MAKE -e check > stdout && { cat stdout; Exit 1; }
149 cat stdout
150 grep foo.test stdout && Exit 1
151 grep bar.test stdout && Exit 1
152 grep baz.test stdout
153
154 :