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