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 { | |
173ee337 | 9 | require './test.pl'; require './charset_tools.pl'; |
25ae1130 RGS |
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 | ||
375f99fd | 24 | my @w_files; |
25ae1130 | 25 | |
375f99fd NC |
26 | if (@ARGV) { |
27 | print "ARGV = [@ARGV]\n"; | |
28 | @w_files = map { "./lib/$pragma_name/$_" } @ARGV; | |
29 | } else { | |
30 | @w_files = sort glob catfile(curdir(), "lib", $pragma_name, "*"); | |
31 | } | |
25ae1130 | 32 | |
fdb35a63 | 33 | my ($tests, @prgs) = setup_multiple_progs(@w_files); |
25ae1130 | 34 | |
11ce4a76 | 35 | $^X = rel2abs($^X); |
96d268e2 | 36 | @INC = map { rel2abs($_) } @INC; |
463cf062 NC |
37 | my $tempdir = tempfile; |
38 | ||
39 | mkdir $tempdir, 0700 or die "Can't mkdir '$tempdir': $!"; | |
40 | chdir $tempdir or die die "Can't chdir '$tempdir': $!"; | |
463cf062 | 41 | my $cleanup = 1; |
463cf062 NC |
42 | |
43 | END { | |
44 | if ($cleanup) { | |
45 | chdir '..' or die "Couldn't chdir .. for cleanup: $!"; | |
ebf2da99 | 46 | rmtree($tempdir); |
463cf062 NC |
47 | } |
48 | } | |
49 | ||
375f99fd NC |
50 | if ($::local_tests && $::local_tests =~ /\D/) { |
51 | # If input is 'no_plan', pass it on unchanged | |
52 | plan $::local_tests; | |
53 | } else { | |
54 | plan $tests + ($::local_tests || 0); | |
55 | } | |
25ae1130 | 56 | |
5f7e0818 | 57 | run_multiple_progs('../..', @prgs); |
25ae1130 | 58 | |
25ae1130 | 59 | 1; |