* tests/gen-tests-deps: Renamed ...
* tests/gen-testsuite-part: ... to this.
* bootstrap: Update.
* tests/Makefile.am ($(srcdir)/tests-deps.am): Don't generate
nor include this ...
($(srcdir)/testsuite-part.am): ... do with this instead.
* tests/.gitignore (tests-deps.am): Don't ignore this ...
(testsuite-part.am): ... ignore this instead.
+2011-09-08 Stefano Lattarini <stefano.lattarini@gmail.com>
+
+ cosmetic: rename gen-tests-deps -> gen-testsuite-part
+ * tests/gen-tests-deps: Renamed ...
+ * tests/gen-testsuite-part: ... to this.
+ * bootstrap: Update.
+ * tests/Makefile.am ($(srcdir)/tests-deps.am): Don't generate
+ nor include this ...
+ ($(srcdir)/testsuite-part.am): ... do with this instead.
+ * tests/.gitignore (tests-deps.am): Don't ignore this ...
+ (testsuite-part.am): ... ignore this instead.
+
2011-09-08 Stefano Lattarini <stefano.lattarini@gmail.com>
testsuite: revamp generation of autogenerated tests
# Create required makefile snippets.
cd tests
-$PERL ./gen-tests-deps > tests-deps.tmp
-chmod a-w tests-deps.tmp
-mv -f tests-deps.tmp tests-deps.am
+$PERL ./gen-testsuite-part > testsuite-part.tmp
+chmod a-w testsuite-part.tmp
+mv -f testsuite-part.tmp testsuite-part.am
cd ..
# Run the autotools.
/aclocal-*
/automake-*
/defs-static
-/tests-deps.am
+/testsuite-part.am
/*-w.tap
/*-w.test
/*.dir
# Automatically-generated tests wrapping hand-written ones.
# Also, automatically-computed dependencies for tests.
-include $(srcdir)/tests-deps.am
+include $(srcdir)/testsuite-part.am
TESTS += $(generated_TESTS)
EXTRA_DIST += $(generated_TESTS)
-$(srcdir)/tests-deps.am:
- $(AM_V_at)rm -f tests-deps.tmp $@
- $(AM_V_GEN)$(PERL) $(srcdir)/gen-tests-deps --srcdir $(srcdir) \
- > tests-deps.tmp
- $(AM_V_at)chmod a-w tests-deps.tmp && mv -f tests-deps.tmp $@
-EXTRA_DIST += gen-tests-deps
+$(srcdir)/testsuite-part.am:
+ $(AM_V_at)rm -f testsuite-part.tmp $@
+ $(AM_V_GEN)$(PERL) $(srcdir)/gen-testsuite-part \
+ --srcdir $(srcdir) > testsuite-part.tmp
+ $(AM_V_at)chmod a-w testsuite-part.tmp
+ $(AM_V_at)mv -f testsuite-part.tmp $@
+EXTRA_DIST += gen-testsuite-part
-$(generated_TESTS) $(srcdir)/tests-deps.am: \
- gen-tests-deps list-of-tests.mk Makefile.am $(handwritten_TESTS)
+$(generated_TESTS) $(srcdir)/testsuite-part.am: \
+ gen-testsuite-part list-of-tests.mk Makefile.am $(handwritten_TESTS)
# Static dependencies valid for each test case.
$(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION)
DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
$(srcdir)/aclocal.in $(srcdir)/automake.in $(srcdir)/defs \
$(srcdir)/defs-static.in $(srcdir)/list-of-tests.mk \
- $(srcdir)/tests-deps.am $(top_srcdir)/CheckListOfTests.am
+ $(srcdir)/testsuite-part.am $(top_srcdir)/CheckListOfTests.am
subdir = tests
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/amversion.m4 \
EXTRA_DIST = ChangeLog-old $(handwritten_TESTS) tap-summary-aux.sh \
tap-setup.sh extract-testsuite-summary \
testsuite-summary-checks.sh trivial-test-driver \
- $(generated_TESTS) gen-tests-deps tap-functions.sh \
+ $(generated_TESTS) gen-testsuite-part tap-functions.sh \
plain-functions.sh
# Hand-written tests.
.SUFFIXES:
.SUFFIXES: .html .log .tap .test .trs
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/list-of-tests.mk $(srcdir)/tests-deps.am $(top_srcdir)/CheckListOfTests.am $(am__configure_deps)
+$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(srcdir)/list-of-tests.mk $(srcdir)/testsuite-part.am $(top_srcdir)/CheckListOfTests.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
tap-recheck-w.log: tap-recheck.test
tap-recheck-w.log: tap-recheck.log
-$(srcdir)/tests-deps.am:
- $(AM_V_at)rm -f tests-deps.tmp $@
- $(AM_V_GEN)$(PERL) $(srcdir)/gen-tests-deps --srcdir $(srcdir) \
- > tests-deps.tmp
- $(AM_V_at)chmod a-w tests-deps.tmp && mv -f tests-deps.tmp $@
+$(srcdir)/testsuite-part.am:
+ $(AM_V_at)rm -f testsuite-part.tmp $@
+ $(AM_V_GEN)$(PERL) $(srcdir)/gen-testsuite-part \
+ --srcdir $(srcdir) > testsuite-part.tmp
+ $(AM_V_at)chmod a-w testsuite-part.tmp
+ $(AM_V_at)mv -f testsuite-part.tmp $@
-$(generated_TESTS) $(srcdir)/tests-deps.am: \
- gen-tests-deps list-of-tests.mk Makefile.am $(handwritten_TESTS)
+$(generated_TESTS) $(srcdir)/testsuite-part.am: \
+ gen-testsuite-part list-of-tests.mk Makefile.am $(handwritten_TESTS)
# Static dependencies valid for each test case.
$(TEST_LOGS): defs defs-static aclocal-$(APIVERSION) automake-$(APIVERSION)
+++ /dev/null
-#! /usr/bin/env perl
-# Automatically compute some dependencies for the hand-written tests
-# of the Automake testsuite. Also, automatically generate some more
-# tests from them (for particular cases/setups only).
-
-# Copyright (C) 2011 Free Software Foundation, Inc.
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2, or (at your option)
-# any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
-
-#--------------------------------------------------------------------------
-
-use warnings FATAL => "all";
-use strict;
-use File::Basename ();
-
-my $me = File::Basename::basename $0;
-
-# For use in VPATH builds.
-my $srcdir = ".";
-
-#--------------------------------------------------------------------------
-
-sub unindent ($)
-{
- my $text = shift;
- $text =~ /^(\s*)/;
- my $indentation = $1;
- $text =~ s/^$indentation//gm;
- return $text;
-}
-
-sub atomic_write ($$;$)
-{
- my ($outfile, $func) = (shift, shift);
- my $perms = @_ > 0 ? shift : 0777;
- my $tmpfile = "$outfile-t";
- foreach my $f ($outfile, $tmpfile)
- {
- unlink $f or die "$me: cannot unlink `$f': $!\n"
- if -e $f;
- }
- open (my $fh, ">$tmpfile")
- or die "$me: can't write to `$tmpfile': $!\n";
- $func->($fh);
- close $fh
- or die "$me: closing `$tmpfile': $!\n";
- chmod ($perms & ~umask, $tmpfile)
- or die "$me: cannot change perms for `$tmpfile': $!\n";
- rename ($tmpfile, $outfile)
- or die "$me: renaming `$tmpfile' -> `$outfile: $!\n'";
-}
-
-sub line_match ($$)
-{
- my ($re, $file) = (shift, shift);
- # Try both curdir and srcdir, with curdir first, to play nice
- # with VPATH builds.
- open (FH, "<$file") or open (FH, "<$srcdir/$file")
- or die "$me: cannot open file `$file': $!\n";
- my $ret = 0;
- while (defined (my $line = <FH>))
- {
- if ($line =~ $re)
- {
- $ret = 1;
- last;
- }
- }
- close FH or die "$me: cannot close file `$file': $!\n";
- return $ret;
-}
-
-sub write_wrapper_script ($$$)
-{
- my ($file_handle, $wrapped_test, $shell_setup_code, $creator_name) = @_;
- print $file_handle unindent <<EOF;
- #! /bin/sh
- # This file has been automatically generated. DO NOT EDIT BY HAND!
- # FIXME: creative quoting to please maintainer-check.
- . ./defs-static || exit '99';
- $shell_setup_code
- # In the spirit of VPATH, we prefer a test in the build tree
- # over one in the source tree.
- for dir in . "\$testsrcdir"; do
- if test -f "\$dir/$wrapped_test"; then
- echo "\$0: will source \$dir/$wrapped_test"
- . "\$dir/$wrapped_test"; exit \$?
- fi
- done
- echo "\$0: cannot find wrapped test \\`$wrapped_test'" >&2
- exit 99
-EOF
-}
-
-sub get_list_of_tests ()
-{
- my $make = defined $ENV{MAKE} ? $ENV{MAKE} : "make";
- # Unset MAKEFLAGS, for when we are called from make itself.
- my $cmd = "MAKEFLAGS= && unset MAKEFLAGS && cd '$srcdir' && "
- . "$make -s -f list-of-tests.mk print-list-of-tests";
- my @tests_list = split /\s+/, `$cmd`;
- die "$me: cannot get list of tests\n" unless $? == 0 && @tests_list;
- my $ok = 1;
- foreach my $test (@tests_list)
- {
- # Respect VPATH builds.
- next if -f $test || -f "$srcdir/$test";
- warn "$me: test `$test' not found\n";
- $ok = 0;
- }
- die "$me: some test scripts not found\n" if !$ok;
- return @tests_list;
-}
-
-sub parse_options (@)
-{
- use Getopt::Long qw/GetOptions/;
- local @ARGV = @_;
- GetOptions ('srcdir=s' => \$srcdir) or die "$me: usage error\n";
- die "$me: too many arguments\n" if @ARGV > 0;
- die "$me: srcdir `$srcdir': not a directory\n" unless -d $srcdir;
-}
-
-#--------------------------------------------------------------------------
-
-my %deps_extractor =
- (
- use_trivial_test_driver =>
- {
- line_matcher => qr/\btrivial-test-driver\b/,
- dist_prereqs => "trivial-test-driver",
- },
- check_testsuite_summary =>
- {
- line_matcher => qr/\btestsuite-summary-checks\.sh\b/,
- dist_prereqs => "testsuite-summary-checks.sh",
- },
- extract_testsuite_summary =>
- {
- line_matcher => qr/\bextract-testsuite-summary\b/,
- dist_prereqs => "extract-testsuite-summary",
- },
- check_tap_testsuite_summary =>
- {
- line_matcher => qr/\btap-summary-aux\.sh\b/,
- dist_prereqs => "tap-summary-aux.sh",
- },
- is_test_on_tap_with_common_setup =>
- {
- line_matcher => qr/\btap-setup\.sh\b/,
- dist_prereqs => "tap-setup.sh",
- nodist_prereqs => "tap-common-setup.log",
- },
- );
-
-#--------------------------------------------------------------------------
-
-my %test_generators =
- (
- #
- # For each test script in the Automake testsuite that itself tests
- # features of the TESTS automake interface, define a sibling test
- # that does likewise, but with the option `parallel-tests' enabled.
- #
- # A test is considered a candidate for sibling-generation if any
- # Makefile.am generated by it define the TESTS variable.
- #
- # Individual tests can prevent the creation of such a sibling by
- # explicitly setting the `$parallel_tests' variable to either "yes"
- # or "no". The rationale for this is that if the variable is set to
- # "yes", the test already uses the `parallel-tests' option, so that
- # a sibling would be just a duplicate; while if the variable is set
- # to "no", the test doesn't support, or is not meant to run with, the
- # `parallel-tests' option, and forcing it to do so in the sibling
- # would likely cause a spurious failure.
- #
- parallel_testsuite_harness =>
- {
- line_matcher =>
- qr/(?:^|\s)TESTS\s*=/,
- line_rejecter =>
- qr/(?:^[^#]*\bparallel-tests\b)|\bparallel_tests=/,
- shell_setup_code =>
- 'parallel_tests=yes'
- },
- #
- # For each test script in the Automake testsuite that tests features
- # of one or more automake-provided shell script from the `lib/'
- # subdirectory by running those scripts directly (i.e., not thought
- # make calls and automake-generated makefiles), define a sibling test
- # that does likewise, but running the said script with the configure
- # time $SHELL instead of the default system shell /bin/sh.
- #
- # A test is considered a candidate for sibling-generation if it calls
- # the `get_shell_script' function anywhere.
- #
- # Individual tests can prevent the creation of such a sibling by
- # explicitly setting the `$test_prefer_config_shell' variable to
- # either "yes" or "no".
- # The rationale for this is that if the variable is set to "yes",
- # the test already uses $SHELL, so that a sibling would be just a
- # duplicate; while if the variable is set to "no", the test doesn't
- # support, or is not meant to use, $SHELL to run the script under
- # testing, and forcing it to do so in the sibling would likely
- # cause a spurious failure.
- #
- prefer_config_shell =>
- {
- line_matcher =>
- qr/(^|\s)get_shell_script\s/,
- line_rejecter =>
- qr/\btest_prefer_config_shell=/,
- shell_setup_code =>
- 'test_prefer_config_shell=yes',
- },
- #
- # Tests on tap support should be run with both the perl and awk
- # implementations of the TAP driver (they run with the awk one
- # by default).
- #
- perl_tap_driver =>
- {
- line_matcher =>
- qr<(?:\bfetch_tap_driver\b|[\s/]tap-setup\.sh\b)>,
- line_rejecter =>
- qr/\bam_tap_implementation=/,
- shell_setup_code =>
- 'am_tap_implementation=perl',
- },
- );
-
-#--------------------------------------------------------------------------
-
-parse_options @ARGV;
-
-my @tests = get_list_of_tests;
-
-print "## -*- Makefile -*-\n";
-print "## Generated by $me. DO NOT EDIT BY HAND!\n\n";
-
-print <<EOF;
-
-## ---------------------------------------------------- ##
-## Autogenerated dependencies for hand-written tests. ##
-## ---------------------------------------------------- ##
-
-EOF
-
-while (my ($k, $x) = each %deps_extractor)
- {
- my $dist_prereqs = $x->{dist_prereqs} || "";
- my $nodist_prereqs = $x->{nodist_prereqs} || "";
- my @logs = grep { line_match $x->{line_matcher}, $_ } @tests;
- map { s/\.[^.]*$//; s/$/\.log/; } @logs;
- print "## Added by deps-extracting key `$k'.\n";
- print "EXTRA_DIST += $dist_prereqs\n";
- map { print "$_: $dist_prereqs $nodist_prereqs\n" } @logs;
- print "\n";
- }
-
-print <<EOF;
-
-## --------------------------------------------- ##
-## Autogenerated tests and their dependencies. ##
-## --------------------------------------------- ##
-
-generated_TESTS =
-
-EOF
-
-# FIXME: the following is not really right, since cannot compose wrapping
-# of tests matching more than one condition. Still, there should be no
-# such test at the moment, so the limitation is (temporarily) acceptable.
-while (my ($k, $g) = each %test_generators)
- {
- my @wrapped_tests = grep {
- line_match ($g->{line_matcher}, $_)
- && !line_match ($g->{line_rejecter}, $_)
- } @tests;
- foreach my $wrapped_test (@wrapped_tests)
- {
- (my $base = $wrapped_test) =~ s/\.([^.]*)$//;
- my $suf = $1 or die "$me: test `$wrapped_test' lacks a suffix\n";
- # Create wrapper test.
- atomic_write "$base-w.$suf",
- sub { write_wrapper_script $_[0], $wrapped_test,
- $g->{shell_setup_code} },
- 0555;
- # Update generated makefile fragment to account for it.
- print "generated_TESTS += $base-w.$suf\n";
- # The generated test works by sourcing the original test, so that
- # it has to be re-run every time that changes ...
- print "$base-w.log: $wrapped_test\n";
- # ... but also every time the prerequisites of the wrapped test
- # changes. The simpler (although suboptimal) way to do so is to
- # ensure that the wrapped tests runs before the wrappee one (in
- # case it needs to be re-run *at all*.
- # FIXME: we could maybe refactor the script to find a more
- # granular way to express such implicit dependencies.
- print "$base-w.log: $base.log\n";
- }
- }
-
-__END__
--- /dev/null
+#! /usr/bin/env perl
+# Automatically compute some dependencies for the hand-written tests
+# of the Automake testsuite. Also, automatically generate some more
+# tests from them (for particular cases/setups only).
+
+# Copyright (C) 2011 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+#--------------------------------------------------------------------------
+
+use warnings FATAL => "all";
+use strict;
+use File::Basename ();
+
+my $me = File::Basename::basename $0;
+
+# For use in VPATH builds.
+my $srcdir = ".";
+
+#--------------------------------------------------------------------------
+
+sub unindent ($)
+{
+ my $text = shift;
+ $text =~ /^(\s*)/;
+ my $indentation = $1;
+ $text =~ s/^$indentation//gm;
+ return $text;
+}
+
+sub atomic_write ($$;$)
+{
+ my ($outfile, $func) = (shift, shift);
+ my $perms = @_ > 0 ? shift : 0777;
+ my $tmpfile = "$outfile-t";
+ foreach my $f ($outfile, $tmpfile)
+ {
+ unlink $f or die "$me: cannot unlink `$f': $!\n"
+ if -e $f;
+ }
+ open (my $fh, ">$tmpfile")
+ or die "$me: can't write to `$tmpfile': $!\n";
+ $func->($fh);
+ close $fh
+ or die "$me: closing `$tmpfile': $!\n";
+ chmod ($perms & ~umask, $tmpfile)
+ or die "$me: cannot change perms for `$tmpfile': $!\n";
+ rename ($tmpfile, $outfile)
+ or die "$me: renaming `$tmpfile' -> `$outfile: $!\n'";
+}
+
+sub line_match ($$)
+{
+ my ($re, $file) = (shift, shift);
+ # Try both curdir and srcdir, with curdir first, to play nice
+ # with VPATH builds.
+ open (FH, "<$file") or open (FH, "<$srcdir/$file")
+ or die "$me: cannot open file `$file': $!\n";
+ my $ret = 0;
+ while (defined (my $line = <FH>))
+ {
+ if ($line =~ $re)
+ {
+ $ret = 1;
+ last;
+ }
+ }
+ close FH or die "$me: cannot close file `$file': $!\n";
+ return $ret;
+}
+
+sub write_wrapper_script ($$$)
+{
+ my ($file_handle, $wrapped_test, $shell_setup_code, $creator_name) = @_;
+ print $file_handle unindent <<EOF;
+ #! /bin/sh
+ # This file has been automatically generated. DO NOT EDIT BY HAND!
+ # FIXME: creative quoting to please maintainer-check.
+ . ./defs-static || exit '99';
+ $shell_setup_code
+ # In the spirit of VPATH, we prefer a test in the build tree
+ # over one in the source tree.
+ for dir in . "\$testsrcdir"; do
+ if test -f "\$dir/$wrapped_test"; then
+ echo "\$0: will source \$dir/$wrapped_test"
+ . "\$dir/$wrapped_test"; exit \$?
+ fi
+ done
+ echo "\$0: cannot find wrapped test \\`$wrapped_test'" >&2
+ exit 99
+EOF
+}
+
+sub get_list_of_tests ()
+{
+ my $make = defined $ENV{MAKE} ? $ENV{MAKE} : "make";
+ # Unset MAKEFLAGS, for when we are called from make itself.
+ my $cmd = "MAKEFLAGS= && unset MAKEFLAGS && cd '$srcdir' && "
+ . "$make -s -f list-of-tests.mk print-list-of-tests";
+ my @tests_list = split /\s+/, `$cmd`;
+ die "$me: cannot get list of tests\n" unless $? == 0 && @tests_list;
+ my $ok = 1;
+ foreach my $test (@tests_list)
+ {
+ # Respect VPATH builds.
+ next if -f $test || -f "$srcdir/$test";
+ warn "$me: test `$test' not found\n";
+ $ok = 0;
+ }
+ die "$me: some test scripts not found\n" if !$ok;
+ return @tests_list;
+}
+
+sub parse_options (@)
+{
+ use Getopt::Long qw/GetOptions/;
+ local @ARGV = @_;
+ GetOptions ('srcdir=s' => \$srcdir) or die "$me: usage error\n";
+ die "$me: too many arguments\n" if @ARGV > 0;
+ die "$me: srcdir `$srcdir': not a directory\n" unless -d $srcdir;
+}
+
+#--------------------------------------------------------------------------
+
+my %deps_extractor =
+ (
+ use_trivial_test_driver =>
+ {
+ line_matcher => qr/\btrivial-test-driver\b/,
+ dist_prereqs => "trivial-test-driver",
+ },
+ check_testsuite_summary =>
+ {
+ line_matcher => qr/\btestsuite-summary-checks\.sh\b/,
+ dist_prereqs => "testsuite-summary-checks.sh",
+ },
+ extract_testsuite_summary =>
+ {
+ line_matcher => qr/\bextract-testsuite-summary\b/,
+ dist_prereqs => "extract-testsuite-summary",
+ },
+ check_tap_testsuite_summary =>
+ {
+ line_matcher => qr/\btap-summary-aux\.sh\b/,
+ dist_prereqs => "tap-summary-aux.sh",
+ },
+ is_test_on_tap_with_common_setup =>
+ {
+ line_matcher => qr/\btap-setup\.sh\b/,
+ dist_prereqs => "tap-setup.sh",
+ nodist_prereqs => "tap-common-setup.log",
+ },
+ );
+
+#--------------------------------------------------------------------------
+
+my %test_generators =
+ (
+ #
+ # For each test script in the Automake testsuite that itself tests
+ # features of the TESTS automake interface, define a sibling test
+ # that does likewise, but with the option `parallel-tests' enabled.
+ #
+ # A test is considered a candidate for sibling-generation if any
+ # Makefile.am generated by it define the TESTS variable.
+ #
+ # Individual tests can prevent the creation of such a sibling by
+ # explicitly setting the `$parallel_tests' variable to either "yes"
+ # or "no". The rationale for this is that if the variable is set to
+ # "yes", the test already uses the `parallel-tests' option, so that
+ # a sibling would be just a duplicate; while if the variable is set
+ # to "no", the test doesn't support, or is not meant to run with, the
+ # `parallel-tests' option, and forcing it to do so in the sibling
+ # would likely cause a spurious failure.
+ #
+ parallel_testsuite_harness =>
+ {
+ line_matcher =>
+ qr/(?:^|\s)TESTS\s*=/,
+ line_rejecter =>
+ qr/(?:^[^#]*\bparallel-tests\b)|\bparallel_tests=/,
+ shell_setup_code =>
+ 'parallel_tests=yes'
+ },
+ #
+ # For each test script in the Automake testsuite that tests features
+ # of one or more automake-provided shell script from the `lib/'
+ # subdirectory by running those scripts directly (i.e., not thought
+ # make calls and automake-generated makefiles), define a sibling test
+ # that does likewise, but running the said script with the configure
+ # time $SHELL instead of the default system shell /bin/sh.
+ #
+ # A test is considered a candidate for sibling-generation if it calls
+ # the `get_shell_script' function anywhere.
+ #
+ # Individual tests can prevent the creation of such a sibling by
+ # explicitly setting the `$test_prefer_config_shell' variable to
+ # either "yes" or "no".
+ # The rationale for this is that if the variable is set to "yes",
+ # the test already uses $SHELL, so that a sibling would be just a
+ # duplicate; while if the variable is set to "no", the test doesn't
+ # support, or is not meant to use, $SHELL to run the script under
+ # testing, and forcing it to do so in the sibling would likely
+ # cause a spurious failure.
+ #
+ prefer_config_shell =>
+ {
+ line_matcher =>
+ qr/(^|\s)get_shell_script\s/,
+ line_rejecter =>
+ qr/\btest_prefer_config_shell=/,
+ shell_setup_code =>
+ 'test_prefer_config_shell=yes',
+ },
+ #
+ # Tests on tap support should be run with both the perl and awk
+ # implementations of the TAP driver (they run with the awk one
+ # by default).
+ #
+ perl_tap_driver =>
+ {
+ line_matcher =>
+ qr<(?:\bfetch_tap_driver\b|[\s/]tap-setup\.sh\b)>,
+ line_rejecter =>
+ qr/\bam_tap_implementation=/,
+ shell_setup_code =>
+ 'am_tap_implementation=perl',
+ },
+ );
+
+#--------------------------------------------------------------------------
+
+parse_options @ARGV;
+
+my @tests = get_list_of_tests;
+
+print "## -*- Makefile -*-\n";
+print "## Generated by $me. DO NOT EDIT BY HAND!\n\n";
+
+print <<EOF;
+
+## ---------------------------------------------------- ##
+## Autogenerated dependencies for hand-written tests. ##
+## ---------------------------------------------------- ##
+
+EOF
+
+while (my ($k, $x) = each %deps_extractor)
+ {
+ my $dist_prereqs = $x->{dist_prereqs} || "";
+ my $nodist_prereqs = $x->{nodist_prereqs} || "";
+ my @logs = grep { line_match $x->{line_matcher}, $_ } @tests;
+ map { s/\.[^.]*$//; s/$/\.log/; } @logs;
+ print "## Added by deps-extracting key `$k'.\n";
+ print "EXTRA_DIST += $dist_prereqs\n";
+ map { print "$_: $dist_prereqs $nodist_prereqs\n" } @logs;
+ print "\n";
+ }
+
+print <<EOF;
+
+## --------------------------------------------- ##
+## Autogenerated tests and their dependencies. ##
+## --------------------------------------------- ##
+
+generated_TESTS =
+
+EOF
+
+# FIXME: the following is not really right, since cannot compose wrapping
+# of tests matching more than one condition. Still, there should be no
+# such test at the moment, so the limitation is (temporarily) acceptable.
+while (my ($k, $g) = each %test_generators)
+ {
+ my @wrapped_tests = grep {
+ line_match ($g->{line_matcher}, $_)
+ && !line_match ($g->{line_rejecter}, $_)
+ } @tests;
+ foreach my $wrapped_test (@wrapped_tests)
+ {
+ (my $base = $wrapped_test) =~ s/\.([^.]*)$//;
+ my $suf = $1 or die "$me: test `$wrapped_test' lacks a suffix\n";
+ # Create wrapper test.
+ atomic_write "$base-w.$suf",
+ sub { write_wrapper_script $_[0], $wrapped_test,
+ $g->{shell_setup_code} },
+ 0555;
+ # Update generated makefile fragment to account for it.
+ print "generated_TESTS += $base-w.$suf\n";
+ # The generated test works by sourcing the original test, so that
+ # it has to be re-run every time that changes ...
+ print "$base-w.log: $wrapped_test\n";
+ # ... but also every time the prerequisites of the wrapped test
+ # changes. The simpler (although suboptimal) way to do so is to
+ # ensure that the wrapped tests runs before the wrappee one (in
+ # case it needs to be re-run *at all*.
+ # FIXME: we could maybe refactor the script to find a more
+ # granular way to express such implicit dependencies.
+ print "$base-w.log: $base.log\n";
+ }
+ }
+
+__END__