am-ft: make the environment available earlier
[platform/upstream/automake.git] / t / parallel-tests-log-override-1.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: runtime redefinition of $(TEST_SUITE_LOG).
18
19 . test-init.sh
20
21 cat >> configure.ac <<'END'
22 AC_OUTPUT
23 END
24
25 cat > Makefile.am <<'END'
26 TESTS = pass.test skip.test xfail.test
27 XFAIL_TESTS = xfail.test
28 EXTRA_DIST = $(TESTS)
29 END
30
31 cat > pass.test <<'END'
32 #! /bin/sh
33 exit 0
34 END
35
36 cat > skip.test <<'END'
37 #! /bin/sh
38 echo "% test skipped %"
39 exit 77
40 END
41
42 cat > xfail.test <<'END'
43 #! /bin/sh
44 echo "# expected failure #"
45 exit 1
46 END
47
48 chmod a+x *.test
49
50 test_log_edit ()
51 {
52   sed -e "s|^  *$me 1\.0:.*$|  $me 1.0: ???|" \
53       -e "s|^=====*|=======================|" $*
54 }
55
56 test_log_expected ()
57 {
58   test_log_edit orig > exp
59   test_log_edit $1   > got
60   diff exp got || exit 1
61   rm -f exp got
62 }
63
64 $ACLOCAL
65 $AUTOCONF
66 $AUTOMAKE -a
67
68 ./configure
69
70 $MAKE check
71 ls -l
72 cat test-suite.log
73 cp test-suite.log orig
74
75 $MAKE clean
76 test -f test-suite.log && exit 99 # Sanity check.
77
78 # Check that we can override the testsuite log file at runtime.
79 run_make TEST_SUITE_LOG=zardoz.log check
80 ls -l
81 test ! -e test-suite.log
82 cat zardoz.log
83 test_log_expected zardoz.log
84 # Sanity check the distribution too (this also does minimal checks on
85 # VPATH support).
86 run_make TEST_SUITE_LOG=zardoz.log distcheck
87
88 # Check that cleanup rules remove the correct file even when
89 # user overrides are in place.
90 cp orig test-suite.log
91 run_make TEST_SUITE_LOG=zardoz.log clean
92 ls -l
93 test ! -e zardoz.log
94 diff orig test-suite.log
95
96 # Check that the default testsuite log doesn't get unduly modified.
97 # Also check that the testsuite log file doesn't need to be named
98 # accordingly to the '*.log' pattern.
99 chmod a-w test-suite.log
100 run_make TEST_SUITE_LOG=TheLogFile check
101 ls -l
102 diff orig test-suite.log
103 test_log_expected TheLogFile
104 run_make TEST_SUITE_LOG=TheLogFile clean
105 ls -l
106 test ! -e TheLogFile
107 diff orig test-suite.log
108
109 :