summaryrefslogtreecommitdiff
path: root/gen-testsuite-part
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-10-26 11:36:12 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-10-26 12:30:04 +0200
commite448fc02db3558219fb0f1a7a1183af77fa90971 (patch)
tree144e8f13be8cc584e31f32627e0eacc585872403 /gen-testsuite-part
parente3b0ad32d023b1553235f2cfe4a94e6ae4743825 (diff)
downloadautomake-e448fc02db3558219fb0f1a7a1183af77fa90971.tar.gz
tests: ensure generation of wrapper tests matching multiple conditions
* gen-testsuite-part: Our old code to generate wrapper tests had a severe limitation, in that if a test matched two or more conditions calling for generation of wrapper tests, still only one wrapper test was generated, instead of the three that would have been expected -- that is, one using the setup code triggered by the first condition, one using the setup code triggered by the second condition, and one using both this setup code fragments. Admittedly, this was only a theoretical limitation for the moment, since since so far no test exists that matches two or more conditions for wrapping. Still, this might change in the future, and easily in an unnoticed way, so better fix the issue now, before it might become a real problem. Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 'gen-testsuite-part')
-rwxr-xr-xgen-testsuite-part52
1 files changed, 35 insertions, 17 deletions
diff --git a/gen-testsuite-part b/gen-testsuite-part
index 57c1c6331..6ed193186 100755
--- a/gen-testsuite-part
+++ b/gen-testsuite-part
@@ -270,37 +270,55 @@ print <<EOF;
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.
-foreach my $g (values %test_generators)
+# A test script '$test' can possibly match more than one condition, so
+# for each tests we need to keep a list of generated wrapper tests.
+# Since what defines these wrapper scripts is the set of initializations
+# that are issued before sourcing the original, wrapped tests, these
+# initializations is what we put in our list entries.
+# The list will be saved in the hash entry '$wrapper_setups{$test}'.
+my %wrapper_setups = ();
+foreach my $test (@all_tests)
{
- my @wrapped_tests = grep {
- line_match ($g->{line_matcher}, $_)
- && (!$g->{line_rejecter} || !line_match ($g->{line_rejecter}, $_))
- } @all_tests;
- foreach my $wrapped_test (@wrapped_tests)
+ my @setups = ('');
+ foreach my $x (values %test_generators)
+ {
+ next
+ if not line_match $x->{line_matcher}, $test;
+ next
+ if $x->{line_rejecter} and line_match $x->{line_rejecter}, $test;
+ @setups = map { ($_, "$_\n$x->{shell_setup_code}") } @setups;
+ }
+ @setups = grep { $_ ne '' } @setups;
+ $wrapper_setups{$test} = \@setups if @setups;
+ }
+# And now create all the wrapper tests.
+while (my ($wrapped_test, $setup_list) = each %wrapper_setups)
+ {
+ (my $base = $wrapped_test) =~ s/\.([^.]*)$//;
+ my $suf = $1 or die "$me: test '$wrapped_test' lacks a suffix\n";
+ my $count = 0;
+ foreach my $setup (@$setup_list)
{
- (my $base = $wrapped_test) =~ s/\.([^.]*)$//;
- my $suf = $1 or die "$me: test '$wrapped_test' lacks a suffix\n";
- my $wrapper_test = "$base-w.$suf";
+ $count++;
+ my $wbase = "$base-w" . ($count > 1 ? $count : '');
+ my $wrapper_test = "$wbase.$suf";
# Register wrapper test as "autogenerated".
push @generated_tests, $wrapper_test;
# Create wrapper test.
atomic_write $wrapper_test,
sub { write_wrapper_script $_[0], $wrapped_test,
- $g->{shell_setup_code} },
+ $setup },
0555;
# 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";
+ print "$wbase.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*.
+ # ensure that the wrapped tests runs before the wrapper 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";
+ print "$wbase.log: $base.log\n";
}
}