diff options
author | Nicholas Clark <nick@ccl4.org> | 2011-03-08 10:31:32 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2011-03-08 10:32:23 +0000 |
commit | 4f018ed094fde8223d458959a30ea42ff841f880 (patch) | |
tree | 6523698ff77c507a6764bc0df2e542c7b514be71 /t/thread_it.pl | |
parent | 224b2e7e6be9296f0761c242069908f4a4e2bf16 (diff) | |
download | perl-4f018ed094fde8223d458959a30ea42ff841f880.tar.gz |
Simplify the logic in t/thread_it.pl, as the callers' filenames are uniform.
VMS invokes TEST with Unix-style filenames, so using / as a separator inside
t/thread_it.pl should not pose a portability problem. ':' is irrelevant now
that MacOS Classic is very "special biologist word".
Diffstat (limited to 't/thread_it.pl')
-rw-r--r-- | t/thread_it.pl | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/t/thread_it.pl b/t/thread_it.pl index cbe979f360..37d4680411 100644 --- a/t/thread_it.pl +++ b/t/thread_it.pl @@ -13,26 +13,24 @@ skip_all_if_miniperl("no dynamic loading on miniperl, no threads"); require threads; -sub thread_it { - # Generate things like './op/regexp.t', './t/op/regexp.t', ':op:regexp.t' - my @paths - = (join ('/', '.', @_), join ('/', '.', 't', @_), join (':', @_)); - - for my $file (@paths) { - if (-r $file) { - print "# found tests in $file\n"; - $::running_as_thread = "running tests in a new thread"; - do $file or die $@; - print "# running tests in a new thread\n"; - my $curr = threads->create(sub { - run_tests(); - return defined &curr_test ? curr_test() : () - })->join(); - curr_test($curr) if defined $curr; - exit; - } - } - die "Cannot find " . join (" or ", @paths) . "\n"; -} +# Which file called us? +my $caller = (caller)[1]; + +die "Can't figure out which test to run from filename '$caller'" + unless $caller =~ m!((?:op|re)/[-_a-z0-9A-Z]+)_thr\.t\z!; + +my $file = "$1.t"; + +$::running_as_thread = "running tests in a new thread"; +require $file; + +note('running tests in a new thread'); + +my $curr = threads->create(sub { + run_tests(); + return defined &curr_test ? curr_test() : () + })->join(); + +curr_test($curr) if defined $curr; 1; |