1 # This code is used by lib/charnames.t, lib/croak.t, lib/feature.t,
2 # lib/subs.t, lib/strict.t and lib/warnings.t
4 # On input, $::local_tests is the number of tests in the caller; or
5 # 'no_plan' if unknown, in which case it is the caller's responsibility
6 # to call cur_test() to find out how many this executed
14 use File::Spec::Functions qw(catfile curdir rel2abs);
18 my (undef, $file) = caller;
19 my ($pragma_name) = $file =~ /([A-Za-z_0-9]+)\.t$/
20 or die "Can't identify pragama to test from file name '$file'";
28 { print "ARGV = [@ARGV]\n" ;
29 @w_files = map { s#^#./lib/$pragma_name/#; $_ } @ARGV
32 { @w_files = sort glob(catfile(curdir(), "lib", $pragma_name, "*")) }
35 foreach my $file (@w_files) {
37 next if $file =~ /(~|\.orig|,v)$/;
38 next if $file =~ /perlio$/ && !(find PerlIO::Layer 'perlio');
41 open my $fh, '<', $file or die "Cannot open $file: $!\n" ;
51 # This is an internal error, and should never happen. All bar one of the
52 # files had an __END__ marker to signal the end of their preamble, although
53 # for some it wasn't technically necessary as they have no tests.
54 # It might be possible to process files without an __END__ by seeking back
55 # to the start and treating the whole file as tests, but it's simpler and
56 # more reliable just to make the rule that all files must have __END__ in.
57 # This should never fail - a file without an __END__ should not have been
58 # checked in, because the regression tests would not have passed.
59 die "Could not find '__END__' in $file"
65 @prgs = (@prgs, $file, split "\n########\n", <$fh>) ;
71 @INC = map { rel2abs($_) } @INC;
72 my $tempdir = tempfile;
74 mkdir $tempdir, 0700 or die "Can't mkdir '$tempdir': $!";
75 chdir $tempdir or die die "Can't chdir '$tempdir': $!";
80 chdir '..' or die "Couldn't chdir .. for cleanup: $!";
87 my $tests = $::local_tests || 0;
88 $tests = scalar(@prgs)-$files + $tests if $tests !~ /\D/;
89 plan $tests; # If input is 'no_plan', pass it on unchanged
91 run_multiple_progs('../..', @prgs);