tests: expose automake bug#14560
[platform/upstream/automake.git] / t / parallel-tests-dry-run-2.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 interactions between the parallel test harness and "make -n".
18 # See also sister test 'parallel-tests-dry-run-1.sh'.
19
20 . test-init.sh
21
22 cat >> configure.ac << 'END'
23 AC_OUTPUT
24 END
25
26 cat > Makefile.am <<'END'
27 TESTS = foo.test bar.test
28 TEST_LOG_COMPILER = $(SHELL)
29 END
30
31 $ACLOCAL
32 $AUTOMAKE -a
33 $AUTOCONF
34
35 ./configure
36
37 make_n_ ()
38 {
39   st=0
40   run_make -M -- -n "$@" || { ls -l; exit 1; }
41   # Look out for possible errors from common tools used by recipes.
42   $EGREP -i ' (exist|permission|denied|no .*(such|file))' output && exit 1
43   $EGREP '(mv|cp|rm|cat|grep|sed|awk): ' output && exit 1
44   :
45 }
46
47 : > output
48
49 files='foo.log bar.log foo.trs bar.trs'
50
51 echo 'exit 0' > foo.test
52 echo 'exit 1' > bar.test
53
54 for target in check recheck test-suite.log; do
55   make_n_ $target
56   test ! -e foo.log
57   test ! -e foo.trs
58   test ! -e bar.log
59   test ! -e bar.trs
60   test ! -e test-suite.log
61 done
62
63 $MAKE check && exit 1
64
65 chmod a-w .
66
67 make_n_ clean
68 test -f foo.log
69 test -f foo.trs
70 test -f foo.log
71 test -f bar.trs
72
73 cat > foo.test <<END
74 echo this is bad
75 exit 1
76 END
77 echo 'exit 0' > bar.test
78
79 for target in check recheck test-suite.log; do
80   make_n_ $target
81   grep '^:test-result: *FAIL' bar.trs
82   grep 'this is bad' foo.log test-suite.log && exit 1
83   : For shells with busted 'set -e'.
84 done
85
86 chmod a-rw $files
87 if test -r foo.log; then
88   : You can still read unreadable files!  Skip these checks.
89 else
90   for target in check recheck test-suite.log; do
91     make_n_ $target
92     for f in $files; do
93       test -f $f && test ! -r $f || exit 1
94     done
95   done
96 fi
97 chmod u+r $files
98
99 chmod u+w .
100 rm -f foo.log bar.trs
101 chmod a-w .
102 for target in check recheck test-suite.log $files; do
103   make_n_ $target
104   test ! -e foo.log
105   test -f foo.trs
106   test ! -e bar.trs
107   test -f bar.log
108 done
109
110 :