tests: avoid a spurious failure on MSYS
[platform/upstream/automake.git] / t / parallel-tests-empty-testlogs.sh
1 #! /bin/sh
2 # Copyright (C) 2011-2013 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 # - empty TESTS
19 # - empty TEST_LOGS
20
21 . test-init.sh
22
23 cat >> configure.ac << 'END'
24 AC_CONFIG_FILES([sub1/Makefile sub2/Makefile])
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am << 'END'
29 SUBDIRS = sub1 sub2
30 END
31
32 mkdir sub1 sub2
33
34 cat > sub1/Makefile.am << 'END'
35 TESTS =
36 END
37
38 # When $(TESTS) is empty, NetBSD 5.1 make ends up defining $(TESTS_LOGS)
39 # to ".log" rather than to the empty string (as would be expected).
40 # But our recipes are smart enough to work around such a botched-up
41 # substitution, so let's not bother too much about it.
42 if using_gmake; then
43   unindent >> sub1/Makefile.am << 'END'
44     check-local:
45         echo $(TEST_LOGS) | grep . && exit 1; exit 0
46 END
47 fi
48
49 cat > sub2/Makefile.am << 'END'
50 TESTS = foo.test
51 END
52
53 cat > sub2/foo.test <<'END'
54 #! /bin/sh
55 exit 0
56 END
57 chmod a+x sub2/foo.test
58
59 $ACLOCAL
60 $AUTOCONF
61 $AUTOMAKE -a
62
63 no_test_has_run ()
64 {
65   ls -1 *.log | grep -v '^test-suite\.log$' | grep . && exit 1
66   grep '^# TOTAL: *0$' test-suite.log
67   :
68 }
69
70 for vpath in : false; do
71   if $vpath; then
72     mkdir build
73     cd build
74     srcdir=..
75   else
76     srcdir=.
77   fi
78   $srcdir/configure
79   cd sub1
80   VERBOSE=yes $MAKE check
81   no_test_has_run
82   cd ../sub2
83   run_make VERBOSE=yes TESTS= check
84   no_test_has_run
85   run_make VERBOSE=yes TEST_LOGS= check
86   no_test_has_run
87   cd ..
88   $MAKE check
89   cat sub2/foo.log
90   $MAKE distclean
91   cd $srcdir
92 done
93
94 :