tests: rename 'tests/' => 't/', '*.test' => '*.sh'
[platform/upstream/automake.git] / t / test-driver-create-log-dir.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 # Custom test drivers: if a log file has a directory component (as in
18 # e.g., 'sub/foo.log'), the Automake test harness must ensure that
19 # directory exists before calling any custom test driver.
20
21 am_parallel_tests=yes
22 . ./defs || Exit 1
23
24 cat >> configure.ac << 'END'
25 AC_OUTPUT
26 END
27
28 cat > Makefile.am << 'END'
29 # The extra '.' components below are meant.
30 TESTS = sub/foo sub/subsub/bar.test ././sub1/./baz
31 $(TESTS):
32 LOG_DRIVER = $(srcdir)/checkdir-driver
33 TEST_LOG_DRIVER = $(LOG_DRIVER)
34 EXTRA_DIST = checkdir-driver
35
36 check-local: $(TEST_SUITE_LOG)
37         test -d sub
38         test -d sub1
39         test -d sub/subsub
40         test -f sub/foo.log
41         test -f sub/subsub/bar.log
42         test -f sub1/baz.log
43         test -f sub/foo.trs
44         test -f sub/subsub/bar.trs
45         test -f sub1/baz.trs
46 END
47
48 cat > checkdir-driver <<'END'
49 #! /bin/sh
50 set -e; set -u
51 while test $# -gt 0; do
52   case $1 in
53     --log-file) log_file=$2; shift;;
54     --trs-file) trs_file=$2; shift;;
55     --test-name|--expect-failure|--color-tests|--enable-hard-errors) shift;;
56     --) shift; break;;
57      *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
58   esac
59   shift
60 done
61 echo "log: $log_file" # For debugging.
62 echo "trs: $trs_file" # Ditto.
63 case $log_file in */*);; *) exit 1;; esac
64 dir_log=`expr "$log_file" : '\(.*\)/[^/]*'`
65 dir_trs=`expr "$trs_file" : '\(.*\)/[^/]*'`
66 echo "dir_log: $dir_log" # For debugging.
67 echo "dir_trs: $dir_trs" # Likewise.
68 test x"$dir_trs" = x"$dir_log" || exit 1
69 test -d "$dir_log" || exit 1
70 echo dummy1 > "$log_file"
71 echo dummy2 > "$trs_file"
72 END
73 chmod a+x checkdir-driver
74
75 $ACLOCAL
76 $AUTOCONF
77 $AUTOMAKE
78
79 ./configure
80 $MAKE check
81 $MAKE distcheck
82
83 :