doc: typos in test file.
[automake.git] / t / test-driver-create-log-dir.sh
blob766212fd50343fd0fec905a1058756ba5a3562db
1 #! /bin/sh
2 # Copyright (C) 2011-2024 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
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.
21 . test-init.sh
23 cat >> configure.ac << 'END'
24 AC_OUTPUT
25 END
27 cat > Makefile.am << 'END'
28 # The extra '.' components below are meant.
29 TESTS = sub/foo sub/subsub/bar.test ././sub1/./baz
30 $(TESTS):
31 LOG_DRIVER = $(srcdir)/checkdir-driver
32 TEST_LOG_DRIVER = $(LOG_DRIVER)
33 EXTRA_DIST = checkdir-driver
35 check-local: $(TEST_SUITE_LOG)
36 test -d sub
37 test -d sub1
38 test -d sub/subsub
39 test -f sub/foo.log
40 test -f sub/subsub/bar.log
41 test -f sub1/baz.log
42 test -f sub/foo.trs
43 test -f sub/subsub/bar.trs
44 test -f sub1/baz.trs
46 # Tell GNU make not to parallelize, since the two tests under sub/
47 # can result in, for example:
48 # fatal: making test-suite.log: failed to create sub/foo.trs
49 # fatal: making test-suite.log: failed to create sub/foo.log
50 # No evident way to debug or reliably reproduce.
51 .NOTPARALLEL:
52 END
54 echo "#!$AM_TEST_RUNNER_SHELL" > checkdir-driver
55 cat >> checkdir-driver <<'END'
56 set -e; set -u
57 while test $# -gt 0; do
58 case $1 in
59 --log-file) log_file=$2; shift;;
60 --trs-file) trs_file=$2; shift;;
61 --test-name|--expect-failure|--color-tests|--enable-hard-errors) shift;;
62 --) shift; break;;
63 *) echo "$0: invalid option/argument: '$1'" >&2; exit 2;;
64 esac
65 shift
66 done
67 echo "log: $log_file" # For debugging.
68 echo "trs: $trs_file" # Ditto.
69 case $log_file in */*);; *) exit 1;; esac
70 dir_log=${log_file%/*}
71 dir_trs=${trs_file%/*}
72 echo "dir_log: $dir_log" # For debugging.
73 echo "dir_trs: $dir_trs" # Likewise.
74 test x"$dir_trs" = x"$dir_log" || exit 1
75 test -d "$dir_log" || exit 1
76 echo dummy1 > "$log_file"
77 echo dummy2 > "$trs_file"
78 END
79 chmod a+x checkdir-driver
81 $ACLOCAL
82 $AUTOCONF
83 $AUTOMAKE
85 ./configure
86 $MAKE check
87 $MAKE distcheck