diff options
Diffstat (limited to 'gen-testsuite-part')
-rwxr-xr-x | gen-testsuite-part | 81 |
1 files changed, 37 insertions, 44 deletions
diff --git a/gen-testsuite-part b/gen-testsuite-part index 46ae56d56..087817aea 100755 --- a/gen-testsuite-part +++ b/gen-testsuite-part @@ -73,10 +73,10 @@ sub atomic_write ($$;$) sub line_match ($$) { my ($re, $file) = (shift, shift); - # Try both builddir and srcdir, with builddir first, to play nice - # with VPATH builds. - open (FH, "<$file") or open (FH, "<$srcdir/$file") - or die "$me: cannot open file '$file': $!\n"; + # Test scripts should always be in srcdir, whether auto-generated + # or not. + open (FH, "<$srcdir/$file") + or die "$me: cannot open file '$srcdir/$file': $!\n"; my $ret = 0; while (defined (my $line = <FH>)) { @@ -98,33 +98,31 @@ sub write_wrapper_script ($$$) # This file has been automatically generated. DO NOT EDIT BY HAND! . test-lib.sh $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 . "\$am_top_srcdir"; 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 + w="\$am_top_srcdir/$wrapped_test" + if test -f "\$w"; then + echo "\$0: will source '\$w'" + . "\$w" + exit \$? + fi + echo "\$0: cannot find wrapped test '\$w'" >&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 $testdir/list-of-tests.mk print-list-of-tests"; - my @tests_list = split /\s+/, `$cmd`; + my @tests_list = split /\s+/, + `cd '$srcdir' && echo $testdir/*.sh $testdir/*.tap`; + # Tests whose names matches this pattern are already autogenerated, + # so we shouldn't re-process them. + @tests_list = grep { !/-w[0-9]*\.(sh|tap)$/ } @tests_list; 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"; + my $test_path = "$srcdir/$test"; + next if -f $test_path; + warn "$me: test '$test_path' not found\n"; $ok = 0; } die "$me: some test scripts not found\n" if !$ok; @@ -164,6 +162,11 @@ my %deps_extractor = line_matcher => qr/\btrivial-test-driver\b/, dist_prereqs => "$testauxdir/trivial-test-driver", }, + depcomp_shuffle => + { + line_matcher => qr/\bdepcomp-shuffle\.sh\b/, + dist_prereqs => "$testauxdir/depcomp-shuffle.sh", + }, check_testsuite_summary => { line_matcher => qr/\btestsuite-summary-checks\.sh\b/, @@ -248,16 +251,15 @@ 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 "## Generated by $me. DO NOT EDIT BY HAND!\n"; print <<EOF; -## --------------------------------------------- ## -## Autogenerated tests and their dependencies. ## -## --------------------------------------------- ## +## --------------------------------------- ## +## Dependencies for autogenerated tests. ## +## --------------------------------------- ## EOF @@ -293,9 +295,7 @@ for my $wrapped_test (sort keys %wrapper_setups) { $count++; my $wbase = "$base-w" . ($count > 1 ? $count : ''); - my $wrapper_test = "$wbase.$suf"; - # Register wrapper test as "autogenerated". - push @generated_tests, $wrapper_test; + my $wrapper_test = "$srcdir/$wbase.$suf"; # Create wrapper test. atomic_write $wrapper_test, sub { write_wrapper_script $_[0], $wrapped_test, @@ -316,13 +316,13 @@ for my $wrapped_test (sort keys %wrapper_setups) print <<EOF; -## ---------------------------------------------------- ## -## Ad-hoc autogenerated tests and their dependencies. ## -## ---------------------------------------------------- ## +## ---------------------------------------------- ## +## Dependencies for ad-hoc autogenerated tests. ## +## ---------------------------------------------- ## EOF -print "## Tests on automatic dependency tracking (see 'depcomp.sh').\n"; +print "## Tests on automatic dependency tracking (see t/ax/depcomp.sh)\n"; # Key: depmode, value: list of required programs. my %depmodes = @@ -360,11 +360,9 @@ foreach my $lt (TRUE, FALSE) "depmode=$m", "depcomp_with_libtool=" . ($lt ? "yes" : "no"), ); - my $test = "$testdir/depcomp" . ($lt ? "-lt-" : "-") . "$m.tap"; - # Register wrapper test as "autogenerated" ... - push @generated_tests, $test; - # ... and create it. - atomic_write ($test, sub + my $testname = "depcomp" . ($lt ? "-lt-" : "-") . $m . ".tap"; + # Create wrapper test. + atomic_write ("$srcdir/$testdir/$testname", sub { my $file_handle = shift; print $file_handle unindent <<EOF; @@ -382,16 +380,11 @@ EOF } } -# Update generated makefile fragment to account for all the generated tests. -print "generated_TESTS =\n"; -map { print "generated_TESTS += $_\n" } @generated_tests; - # 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; +@all_tests = get_list_of_tests; print <<EOF; |