skip_all 'perl 5.13.4 required to test thread safety'
unless $force or "$]" >= 5.013_004;
- if (($INC{'Test/More.pm'} || $INC{'Test/Leaner.pm'}) && !$INC{'threads.pm'}) {
- die 'Test::More/Test::Leaner was loaded too soon';
+ unless ($INC{'threads.pm'}) {
+ my $test_module;
+ if ($INC{'Test/Leaner.pm'}) {
+ $test_module = 'Test::Leaner';
+ } elsif ($INC{'Test/More.pm'}) {
+ $test_module = 'Test::More';
+ }
+ die "$test_module was loaded too soon" if defined $test_module;
}
load_or_skip_all 'threads', $force ? '0' : '1.67', [ ];
BEGIN { $ENV{PERL_FORCE_TEST_THREADS} = 1 }
-use Test::More tests => 1;
+use Test::More;
-local $@;
-eval 'use VPIT::TestHelpers "threads";';
-like $@, qr/was loaded too soon/, 'cannot use the threads feature after Test::More was loaded';
+use Config;
+plan skip_all => 'Cannot test late loading on a non threaded perl'
+ unless $Config::Config{useithreads};
+
+plan tests => 2;
+
+{
+ local $@;
+ eval 'use VPIT::TestHelpers "threads";';
+ like $@, qr/^Test::More was loaded too soon/,
+ 'cannot use the threads feature after Test::More was loaded';
+}
+
+SKIP: {
+ local $@;
+ eval { require Test::Leaner; 1 } or skip 'No Test::Leaner available' => 1;
+ eval 'use VPIT::TestHelpers "threads";';
+ like $@, qr/^Test::Leaner was loaded too soon/,
+ 'cannot use the threads feature after Test::Leaner was loaded';
+}