diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2011-12-23 22:14:50 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2011-12-23 22:14:50 +0100 |
commit | c3bcf99ccfdb499e0e97128910a5d920ab5338f0 (patch) | |
tree | 5012090cd2196727a4168b32b9db7fc057a6161c | |
parent | ca63bc9fe2331a1d83dc35a3af1efeb64fb204d5 (diff) | |
download | automake-c3bcf99ccfdb499e0e97128910a5d920ab5338f0.tar.gz |
tests: automatically handle deps also for generated tests
* tests/gen-testsuite-part: The test scripts are now scanned for
automatic dependency generation *after* the auto-generated tests
have been created, so they too will be scanned. It is a little
tricky to ensure that the freshly-generated tests are correctly
scanned, and we do that with the help of ...
(@generated_tests): ... this new variable.
Other related minor changes and refactorings.
-rw-r--r-- | ChangeLog | 11 | ||||
-rwxr-xr-x | tests/gen-testsuite-part | 62 |
2 files changed, 48 insertions, 25 deletions
@@ -1,5 +1,16 @@ 2011-12-23 Stefano Lattarini <stefano.lattarini@gmail.com> + tests: automatically handle deps also for generated tests + * tests/gen-testsuite-part: The test scripts are now scanned for + automatic dependency generation *after* the auto-generated tests + have been created, so they too will be scanned. It is a little + tricky to ensure that the freshly-generated tests are correctly + scanned, and we do that with the help of ... + (@generated_tests): ... this new variable. + Other related minor changes and refactorings. + +2011-12-23 Stefano Lattarini <stefano.lattarini@gmail.com> + tests: auto-generate deps for tests requiring libtool/gettext * tests/gen-testsuite-part: Tests requiring libtool (or related programs) will need libtool-provided m4 macros, so they should diff --git a/tests/gen-testsuite-part b/tests/gen-testsuite-part index 091009261..51b634fe9 100755 --- a/tests/gen-testsuite-part +++ b/tests/gen-testsuite-part @@ -256,35 +256,13 @@ my %test_generators = parse_options @ARGV; my @all_tests = get_list_of_tests; +my @generated_tests = (); # Will be updated later. 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 @tests = grep { line_match $x->{line_matcher}, $_ } @all_tests; - map { s/\.[^.]*$//; s/$/\.log/; } (my @logs = @tests); - print "## Added by deps-extracting key `$k'.\n"; - ## The list of all tests which have a dependency detected by the - ## current key. - print join(" \\\n ", "${k}_TESTS =", @tests) . "\n"; - print "EXTRA_DIST += $dist_prereqs\n"; - map { print "$_: $dist_prereqs $nodist_prereqs\n" } @logs; - print "\n"; - } - -print <<EOF; - ## --------------------------------------------- ## ## Autogenerated tests and their dependencies. ## ## --------------------------------------------- ## @@ -306,13 +284,16 @@ while (my ($k, $g) = each %test_generators) { (my $base = $wrapped_test) =~ s/\.([^.]*)$//; my $suf = $1 or die "$me: test `$wrapped_test' lacks a suffix\n"; + my $wrapper_test = "$base-w.$suf"; + # Register wrapper test as "autogenerated". + push @generated_tests, $wrapper_test; # Create wrapper test. - atomic_write "$base-w.$suf", + atomic_write $wrapper_test, 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"; + print "generated_TESTS += $wrapper_test\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"; @@ -326,4 +307,35 @@ while (my ($k, $g) = each %test_generators) } } +# The test scripts are scanned for automatic dependency generation *after* +# the generated tests have been created, so they too can be scanned. To +# do so correctly, we need to update the list in `@all_tests' to make it +# comprise also the freshly-generated tests. + +push @all_tests, @generated_tests; + +print <<EOF; + +## ----------------------------- ## +## Autogenerated dependencies. ## +## ----------------------------- ## + +EOF + +while (my ($k, $x) = each %deps_extractor) + { + my $dist_prereqs = $x->{dist_prereqs} || ""; + my $nodist_prereqs = $x->{nodist_prereqs} || ""; + my @tests = grep { line_match $x->{line_matcher}, $_ } @all_tests; + map { s/\.[^.]*$//; s/$/\.log/; } (my @logs = @tests); + print "## Added by deps-extracting key `$k'.\n"; + ## The list of all tests which have a dependency detected by the + ## current key. + print join(" \\\n ", "${k}_TESTS =", @tests) . "\n"; + print "EXTRA_DIST += $dist_prereqs\n"; + map { print "$_: $dist_prereqs $nodist_prereqs\n" } @logs; + print "\n"; + } + + __END__ |