summaryrefslogtreecommitdiff
path: root/t/thread_it.pl
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-09 22:42:04 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-09 22:42:04 +0000
commite3faa678eb30e1e08116ca1bd086624974e5e5aa (patch)
tree58510d25dc079e3b347ee9b84a8d5e4962f36241 /t/thread_it.pl
parent89eb5450df838ee8565c99567ce367f194dbe60f (diff)
downloadperl-e3faa678eb30e1e08116ca1bd086624974e5e5aa.tar.gz
Variants of several regression tests that run the actul tests inside
a new thread, to test ithread's cloning, particularly of regexps. p4raw-id: //depot/perl@32931
Diffstat (limited to 't/thread_it.pl')
-rw-r--r--t/thread_it.pl39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/thread_it.pl b/t/thread_it.pl
new file mode 100644
index 0000000000..feec254664
--- /dev/null
+++ b/t/thread_it.pl
@@ -0,0 +1,39 @@
+#!perl
+use strict;
+use warnings;
+
+use Config;
+if (!$Config{useithreads}) {
+ print "1..0 # Skip: no ithreads\n";
+ exit 0;
+}
+if ($ENV{PERL_CORE_MINITEST}) {
+ print "1..0 # Skip: no dynamic loading on miniperl, no threads\n";
+ exit 0;
+}
+
+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";
+}
+
+1;