From: Vincent Pit Date: Thu, 19 Mar 2015 19:24:41 +0000 (-0300) Subject: Croak if the threads feature is enabled after Test::More/Leaner was loaded X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=785a5704ffa33a0a69be4982e7e9864eea06ece3;p=perl%2Fmodules%2FVPIT-TestHelpers.git Croak if the threads feature is enabled after Test::More/Leaner was loaded --- diff --git a/lib/VPIT/TestHelpers.pm b/lib/VPIT/TestHelpers.pm index c57826a..2d49da5 100644 --- a/lib/VPIT/TestHelpers.pm +++ b/lib/VPIT/TestHelpers.pm @@ -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 index 0000000..5eea92a --- /dev/null +++ b/t/44-threads-too-late.t @@ -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';