]> git.vpit.fr Git - perl/modules/VPIT-TestHelpers.git/commitdiff
Croak if the threads feature is enabled after Test::More/Leaner was loaded
authorVincent Pit <vince@profvince.com>
Thu, 19 Mar 2015 19:24:41 +0000 (16:24 -0300)
committerVincent Pit <vince@profvince.com>
Thu, 19 Mar 2015 19:24:41 +0000 (16:24 -0300)
lib/VPIT/TestHelpers.pm
t/44-threads-too-late.t [new file with mode: 0644]

index c57826a1cab46cb246931b36af0a5e67d0bda138..2d49da581febc29efdb1bcb1943a1c27db496b30 100644 (file)
@@ -170,6 +170,10 @@ sub init_threads {
  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';
+ }
+
  load_or_skip_all 'threads',         $force ? '0' : '1.67', [ ];
  load_or_skip_all 'threads::shared', $force ? '0' : '1.14', [ ];
 
diff --git a/t/44-threads-too-late.t b/t/44-threads-too-late.t
new file mode 100644 (file)
index 0000000..5eea92a
--- /dev/null
@@ -0,0 +1,12 @@
+#!perl -T
+
+use strict;
+use warnings;
+
+BEGIN { $ENV{PERL_FORCE_TEST_THREADS} = 1 }
+
+use Test::More tests => 1;
+
+local $@;
+eval 'use VPIT::TestHelpers "threads";';
+like $@, qr/was loaded too soon/, 'cannot use the threads feature after Test::More was loaded';