X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=t%2F31-threads-teardown.t;h=34e61acd2a75543af35eed20019f57a7c78a932c;hb=2ca2925dc02c506e0c026e262bbcb4e7a1e18b27;hp=632293b6373a5057c3e609da3e8e51a720686a62;hpb=333c198120153b0cfe076fcb54e100dcf0eb9fb4;p=perl%2Fmodules%2FLexical-Types.git diff --git a/t/31-threads-teardown.t b/t/31-threads-teardown.t index 632293b..34e61ac 100644 --- a/t/31-threads-teardown.t +++ b/t/31-threads-teardown.t @@ -3,14 +3,20 @@ use strict; use warnings; -use Config qw/%Config/; +sub skipall { + my ($msg) = @_; + require Test::More; + Test::More::plan(skip_all => $msg); +} + +use Config qw<%Config>; BEGIN { - if (!$Config{useithreads}) { - require Test::More; - Test::More->import; - plan(skip_all => 'This perl wasn\'t built to support threads'); - } + my $force = $ENV{PERL_LEXICAL_TYPES_TEST_THREADS} ? 1 : !1; + skipall 'This perl wasn\'t built to support threads' + unless $Config{useithreads}; + skipall 'perl 5.13.4 required to test thread safety' + unless $force or "$]" >= 5.013004; } use threads; @@ -19,24 +25,25 @@ use Test::More; BEGIN { require Lexical::Types; - if (Lexical::Types::LT_THREADSAFE()) { - plan tests => 1; - defined and diag "Using threads $_" for $threads::VERSION; - } else { - plan skip_all => 'This Lexical::Types isn\'t thread safe'; - } + skipall 'This Lexical::Types isn\'t thread safe' + unless Lexical::Types::LT_THREADSAFE(); + plan tests => 1; + defined and diag "Using threads $_" for $threads::VERSION; } sub run_perl { my $code = shift; + my $SystemRoot = $ENV{SystemRoot}; local %ENV; + $ENV{SystemRoot} = $SystemRoot if $^O eq 'MSWin32' and defined $SystemRoot; + system { $^X } $^X, '-T', map("-I$_", @INC), '-e', $code; } SKIP: { - skip 'Fails on 5.8.2 and lower' => 1 if $] <= 5.008002; + skip 'Fails on 5.8.2 and lower' => 1 if "$]" <= 5.008002; my $status = run_perl <<' RUN'; { package IntX; package IntY; package IntZ; } @@ -48,11 +55,11 @@ SKIP: } use threads; $code = threads->create(sub { - $code = @expected = qw/IntX/; + $code = @expected = qw; eval q{use Lexical::Types as => \&cb; my IntX $x;}; die if $@; return $code; })->join; - $code += @expected = qw/IntZ/; + $code += @expected = qw; eval q{my IntY $y;}; die if $@; eval q{use Lexical::Types as => \&cb; my IntZ $z;}; die if $@; $code += 256 if $code < 0;