Merge branch 'master' into test-protocols
[platform/upstream/automake.git] / tests / tap-more2.test
1 #! /bin/sh
2 # Copyright (C) 2011 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 # More on TAP support:
18 #  - more LOG_COMPILER at once for TAP tests
19 #  - binary programs in $(TESTS)
20 #  - interactions with `check_*' variables
21
22 required='cc native'
23 parallel_tests=yes
24 . ./defs || Exit 1
25
26 cp "$top_testsrcdir"/lib/tap-driver . \
27   || fatal_ "failed to fetch auxiliary script tap-driver"
28
29 cat >> configure.in <<END
30 AC_PROG_CC
31 AC_SUBST([PERL], ['$PERL'])
32 AC_OUTPUT
33 END
34
35 cat > Makefile.am << 'END'
36 TEST_EXTENSIONS = .sh .tap
37
38 tap_driver = $(PERL) $(srcdir)/tap-driver
39
40 LOG_DRIVER = $(tap_driver)
41 SH_LOG_DRIVER = $(tap_driver)
42 TAP_LOG_DRIVER = $(tap_driver)
43
44 TAP_LOG_COMPILER = cat
45 SH_LOG_COMPILER = $(SHELL)
46 LOG_COMPILER =
47
48 EXTRA_DIST = baz.tap
49
50 check_SCRIPTS = bar.sh
51 bar.sh: Makefile
52         echo '#!/bin/sh' > $@-t
53         echo 'echo 1..1' >> $@-t
54         echo 'echo "not ok 1 # TODO"' >> $@-t
55         chmod a-w $@-t && mv -f $@-t $@
56 CLEANFILES = bar.sh
57
58 check_PROGRAMS = foo-test
59 foo_test_SOURCES = foo.c
60
61 TESTS = foo-test $(check_SCRIPTS) baz.tap
62
63 EXTRA_DIST += tap-driver
64 END
65
66 cat > foo.c <<'END'
67 #include <stdio.h>
68 int main (void)
69 {
70   printf ("1..1\n");
71   printf ("ok 1\n");
72   return 0;
73 }
74 END
75
76 cat > baz.tap << 'END'
77 1..1
78 ok 1 # SKIP
79 END
80
81 $ACLOCAL
82 $AUTOCONF
83 $AUTOMAKE
84
85 ./configure
86
87 for target in check distcheck; do
88   $MAKE $target >stdout || { cat stdout; Exit 1; }
89   cat stdout
90   count_test_results total=3 pass=1 fail=0 xpass=0 xfail=1 skip=1 error=0
91 done
92
93 :