This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Regen known_pod_issues.dat
[perl5.git] / t / thread_it.pl
CommitLineData
e3faa678
NC
1#!perl
2use strict;
3use 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.
10require './test.pl';
11skip_all_without_config('useithreads');
12skip_all_if_miniperl("no dynamic loading on miniperl, no threads");
e3faa678
NC
13
14require threads;
15
4f018ed0
NC
16# Which file called us?
17my $caller = (caller)[1];
18
19die "Can't figure out which test to run from filename '$caller'"
20 unless $caller =~ m!((?:op|re)/[-_a-z0-9A-Z]+)_thr\.t\z!;
21
22my $file = "$1.t";
23
24$::running_as_thread = "running tests in a new thread";
25require $file;
26
27note('running tests in a new thread');
28
29my $curr = threads->create(sub {
30 run_tests();
31 return defined &curr_test ? curr_test() : ()
32 })->join();
33
34curr_test($curr) if defined $curr;
e3faa678
NC
35
361;