This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
podcheck.t: fix up known issues in new perldelta
[perl5.git] / t / thread_it.pl
index cbe979f..37d4680 100644 (file)
@@ -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;