Commit | Line | Data |
---|---|---|
e3faa678 NC |
1 | #!perl |
2 | use strict; | |
3 | use warnings; | |
4 | ||
dd249ef4 NC |
5 | # As perlfunc.pod says: |
6 | # Note that the file will not be included twice under the same specified name. | |
7 | # So ensure that this, textually, is the same name as all the loaded tests use. | |
8 | # Otherwise if we require 'test.pl' and they require './test.pl', it is loaded | |
9 | # twice. | |
10 | require './test.pl'; | |
11 | skip_all_without_config('useithreads'); | |
12 | skip_all_if_miniperl("no dynamic loading on miniperl, no threads"); | |
e3faa678 NC |
13 | |
14 | require threads; | |
15 | ||
16 | sub thread_it { | |
17 | # Generate things like './op/regexp.t', './t/op/regexp.t', ':op:regexp.t' | |
18 | my @paths | |
19 | = (join ('/', '.', @_), join ('/', '.', 't', @_), join (':', @_)); | |
20 | ||
21 | for my $file (@paths) { | |
22 | if (-r $file) { | |
23 | print "# found tests in $file\n"; | |
24 | $::running_as_thread = "running tests in a new thread"; | |
25 | do $file or die $@; | |
26 | print "# running tests in a new thread\n"; | |
27 | my $curr = threads->create(sub { | |
28 | run_tests(); | |
29 | return defined &curr_test ? curr_test() : () | |
30 | })->join(); | |
31 | curr_test($curr) if defined $curr; | |
32 | exit; | |
33 | } | |
34 | } | |
35 | die "Cannot find " . join (" or ", @paths) . "\n"; | |
36 | } | |
37 | ||
38 | 1; |