automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[FYI] {testsuite-work} tests: automatically handle deps also for generat


From: Stefano Lattarini
Subject: [FYI] {testsuite-work} tests: automatically handle deps also for generated tests
Date: Fri, 23 Dec 2011 22:28:45 +0100

* 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.
---
 ChangeLog                |   11 ++++++++
 tests/gen-testsuite-part |   62 +++++++++++++++++++++++++++------------------
 2 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index afd6a10..2c5cf2f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 2011-12-23  Stefano Lattarini  <address@hidden>
 
+       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  <address@hidden>
+
        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 0910092..51b634f 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 address@hidden' 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__
-- 
1.7.7.3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]