Commit | Line | Data |
---|---|---|
59e38755 TC |
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 | |
3d243db0 KW |
3 | # |
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 | |
25ae1130 RGS |
7 | |
8 | BEGIN { | |
25ae1130 RGS |
9 | require './test.pl'; |
10 | } | |
11 | ||
afb1190b | 12 | use Config; |
ebf2da99 | 13 | use File::Path; |
11ce4a76 | 14 | use File::Spec::Functions qw(catfile curdir rel2abs); |
25ae1130 RGS |
15 | |
16 | use strict; | |
742dc32d | 17 | use warnings; |
a80e93c2 NC |
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'"; | |
25ae1130 RGS |
21 | |
22 | $| = 1; | |
23 | ||
25ae1130 RGS |
24 | my @prgs = () ; |
25 | my @w_files = () ; | |
26 | ||
27 | if (@ARGV) | |
28 | { print "ARGV = [@ARGV]\n" ; | |
25ae1130 | 29 | @w_files = map { s#^#./lib/$pragma_name/#; $_ } @ARGV |
25ae1130 RGS |
30 | } |
31 | else | |
32 | { @w_files = sort glob(catfile(curdir(), "lib", $pragma_name, "*")) } | |
33 | ||
34 | my $files = 0; | |
35 | foreach my $file (@w_files) { | |
36 | ||
37 | next if $file =~ /(~|\.orig|,v)$/; | |
38 | next if $file =~ /perlio$/ && !(find PerlIO::Layer 'perlio'); | |
39 | next if -d $file; | |
40 | ||
8606a93d | 41 | open my $fh, '<', $file or die "Cannot open $file: $!\n" ; |
25ae1130 | 42 | my $line = 0; |
8606a93d | 43 | while (<$fh>) { |
25ae1130 RGS |
44 | $line++; |
45 | last if /^__END__/ ; | |
46 | } | |
47 | ||
48 | { | |
49 | local $/ = undef; | |
50 | $files++; | |
8606a93d | 51 | @prgs = (@prgs, $file, split "\n########\n", <$fh>) ; |
25ae1130 | 52 | } |
8606a93d | 53 | close $fh; |
25ae1130 RGS |
54 | } |
55 | ||
11ce4a76 | 56 | $^X = rel2abs($^X); |
463cf062 NC |
57 | my $tempdir = tempfile; |
58 | ||
59 | mkdir $tempdir, 0700 or die "Can't mkdir '$tempdir': $!"; | |
60 | chdir $tempdir or die die "Can't chdir '$tempdir': $!"; | |
61 | unshift @INC, '../../lib'; | |
62 | my $cleanup = 1; | |
463cf062 NC |
63 | |
64 | END { | |
65 | if ($cleanup) { | |
66 | chdir '..' or die "Couldn't chdir .. for cleanup: $!"; | |
ebf2da99 | 67 | rmtree($tempdir); |
463cf062 NC |
68 | } |
69 | } | |
70 | ||
3d243db0 | 71 | local $/ = undef; |
25ae1130 | 72 | |
3d243db0 KW |
73 | my $tests = $::local_tests || 0; |
74 | $tests = scalar(@prgs)-$files + $tests if $tests !~ /\D/; | |
75 | plan $tests; # If input is 'no_plan', pass it on unchanged | |
25ae1130 | 76 | |
5f7e0818 | 77 | run_multiple_progs('../..', @prgs); |
25ae1130 | 78 | |
25ae1130 | 79 | 1; |