Merge branch 'maint'
[platform/upstream/automake.git] / t / ax / testsuite-summary-checks.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 the testsuite summary with the parallel test harness.  This
18 # script is meant to be sourced by other test script, so that it can
19 # be used to check different scenarios (colorized and non-colorized
20 # testsuite output, packages with and without bug-report addresses,
21 # testsuites in subdirectories, ...)
22
23 . ./defs || exit 1
24
25 case $use_colors in
26   yes)
27     AM_COLOR_TESTS=always; export AM_COLOR_TESTS
28     # Forced colorization should take place also with non-ANSI
29     # terminals; hence this setting.
30     TERM=dumb; export TERM
31     am_opts='color-tests'
32     ;;
33   no)
34     am_opts=''
35     ;;
36   *)
37     fatal_ "invalid use_colors='$use_colors'";;
38 esac
39
40 cat > configure.ac <<END
41 AC_INIT([GNU AutoFoo], [7.1], [bug-automake@gnu.org])
42 AM_INIT_AUTOMAKE([$am_opts])
43 AC_CONFIG_FILES([Makefile])
44 AC_OUTPUT
45 END
46
47 cat > Makefile.am <<'END'
48 TEST_EXTENSIONS = .t
49 T_LOG_COMPILER = $(SHELL) $(srcdir)/log-compiler
50 ## Will be defined at runtime.
51 TESTS =
52 $(TESTS):
53 END
54
55 cat > log-compiler <<'END'
56 #!/bin/sh
57 case "$1" in
58   pass*|*/pass*|xpass*|*/xpass*) exit 0;;
59   fail*|*/fail*|xfail*|*/xfail*) exit 1;;
60   skip*|*/skip*) exit 77;;
61   error*|/error*) exit 99;;
62   copy*|*/copy*) cat "$1";;
63   *) exit 99;;
64 esac
65 END
66
67 # Quite complexish, but allow the tests in client scripts to be written
68 # in a "data-driven fashion".
69 do_check ()
70 {
71   cat > summary.exp
72   expect_failure=false
73   xfail_tests=''
74   tests="TESTS='$*'"
75   for t in $*; do
76     case $t in fail*|xpass*|error*) expect_failure=:;; esac
77     case $t in xfail*|xpass*) xfail_tests="$xfail_tests $t";; esac
78   done
79   test -z "$xfail_tests" || xfail_tests="XFAIL_TESTS='$xfail_tests'"
80   st=0
81   eval "env $tests $xfail_tests \$MAKE -e check > stdout || st=\$?"
82   cat stdout
83   if $expect_failure; then
84     test $st -gt 0 || exit 1
85   else
86     test $st -eq 0 || exit 1
87   fi
88   $PERL "$am_testauxdir"/extract-testsuite-summary.pl stdout >summary.got \
89    || fatal_ "cannot extract testsuite summary"
90   cat summary.exp
91   cat summary.got
92   if test $use_colors = yes; then
93     # Use cmp, not diff, because the files might contain binary data.
94     compare=cmp
95   else
96     compare=diff
97   fi
98   $compare summary.exp summary.got || exit 1
99 }
100
101 br='============================================================================'
102
103 $ACLOCAL
104 $AUTOCONF
105 $AUTOMAKE --add-missing
106
107 :