test harness: improve catching of usage errors in script 'test-driver'
[platform/upstream/automake.git] / t / test-driver-acsubst.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 # parallel-tests:
18 #  - LOG_DRIVER variables can be AC_SUBST'd
19
20 . test-init.sh
21
22 mkdir test-drivers
23
24 cp "$am_testaux_srcdir"/trivial-test-driver test-drivers/triv \
25   || fatal_ "failed to fetch auxiliary script trivial-test-driver"
26 cp "$am_scriptdir"/test-driver test-drivers/dflt \
27   || fatal_ "failed to fetch auxiliary script test-driver"
28
29 cat >> configure.ac <<'END'
30 AC_SUBST([LOG_DRIVER],      ['${SHELL} test-drivers/triv'])
31 AC_SUBST([TEST_LOG_DRIVER], ['${SHELL} test-drivers/dflt'])
32 AC_SUBST([SH_LOG_DRIVER],   ['${my_drv}'])
33 AC_OUTPUT
34 END
35
36 cat > Makefile.am <<'END'
37 TEST_EXTENSIONS = .test .sh
38 my_drv = $(SHELL) test-drivers/dflt
39 TESTS = foo bar.test baz.sh
40 XFAIL_TESTS = baz.sh
41 .PHONY: check-autodefs
42 check-autodefs:
43 ### For debugging.
44         @echo      LOG_DRIVER = $(LOG_DRIVER)
45         @echo TEST_LOG_DRIVER = $(TEST_LOG_DRIVER)
46         @echo   SH_LOG_DRIVER = $(SH_LOG_DRIVER)
47 ### Checks here.
48         @echo ' ' $(LOG_DRIVER)      ' ' | grep ' test-drivers/triv '
49         @echo ' ' $(TEST_LOG_DRIVER) ' ' | grep ' test-drivers/dflt '
50         @echo ' ' $(SH_LOG_DRIVER)   ' ' | grep ' test-drivers/dflt '
51 END
52
53 $ACLOCAL
54 $AUTOMAKE
55 $AUTOCONF
56
57 ./configure
58
59 cat > foo <<'END'
60 #!/bin/sh
61 echo "PASS: from $0"
62 exit 1 # exit status should be ignored by the trivial-test-driver.
63 END
64
65 cat > bar.test <<'END'
66 #!/bin/sh
67 exit 77
68 END
69
70 cat > baz.sh <<'END'
71 #!/bin/sh
72 exit 1
73 END
74
75 chmod a+x foo bar.test baz.sh
76
77 $MAKE check-autodefs
78 run_make -O -e IGNORE check
79 cat test-suite.log
80 cat foo.log
81 cat bar.log
82 cat baz.log
83 test $am_make_rc -eq 0
84 count_test_results total=3 pass=1 fail=0 skip=1 xfail=1 xpass=0 error=0
85
86 :