From: Graham Knop Date: Mon, 13 Feb 2017 06:29:15 +0000 (-0500) Subject: use inlined module hiding in tests X-Git-Tag: 5.90116~15 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=10542b5178b2fa036e0658111523ea68a7a04437 use inlined module hiding in tests Test::Without::Module and Devel::Hide both handle repeated module loading wrong. They also generate error messages that aren't compatible with Class::Load. Also add some module hiding for 'Foo' and 'Bar', as they may exist locally, breaking tests. --- diff --git a/Makefile.PL b/Makefile.PL index 5a47d3e..5451d90 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -120,7 +120,6 @@ author_requires( @author_requires, map {; $_ => 0 } qw( File::Copy::Recursive - Test::Without::Module Starman MooseX::Daemonize Test::NoTabs diff --git a/t/aggregate/unit_core_script_server-without_modules.t b/t/aggregate/unit_core_script_server-without_modules.t index 0fdaa87..d6bbcaf 100644 --- a/t/aggregate/unit_core_script_server-without_modules.t +++ b/t/aggregate/unit_core_script_server-without_modules.t @@ -10,26 +10,19 @@ BEGIN { $ENV{PACKAGE_STASH_IMPLEMENTATION} = 'PP' if $] < '5.008007' } use Test::More; use Try::Tiny; -plan skip_all => "Need Test::Without::Module for this test" - unless try { require Test::Without::Module; 1 }; - -Test::Without::Module->import(qw( +my %hidden = map { (my $m = "$_.pm") =~ s{::}{/}g; $m => 1 } qw( Starman::Server Plack::Handler::Starman MooseX::Daemonize MooseX::Daemonize::Pid::File MooseX::Daemonize::Core -)); - -require "$Bin/../aggregate/unit_core_script_server.t"; +); +local @INC = (sub { + return unless exists $hidden{$_[1]}; + die "Can't locate $_[1] in \@INC (hidden)\n"; +}, @INC); -Test::Without::Module->unimport(qw( - Starman::Server - Plack::Handler::Starman - MooseX::Daemonize - MooseX::Daemonize::Pid::File - MooseX::Daemonize::Core -)); +do "$Bin/../aggregate/unit_core_script_server.t" + or die $@ || 'test returned false'; 1; - diff --git a/t/class_traits.t b/t/class_traits.t index edccea2..d6a0c50 100644 --- a/t/class_traits.t +++ b/t/class_traits.t @@ -4,6 +4,17 @@ use Test::More; use Class::MOP; BEGIN { + my %hidden = map { (my $m = "$_.pm") =~ s{::}{/}g; $m => 1 } qw( + Foo + Bar + ); + unshift @INC, sub { + return unless exists $hidden{$_[1]}; + die "Can't locate $_[1] in \@INC (hidden)\n"; + }; +} + +BEGIN { package TestRole; $INC{'TestRole'} = __FILE__; use Moose::Role; @@ -30,7 +41,7 @@ BEGIN { sub c { 'c' } - package TestApp::TraitFor::Response::Bar; + package TestApp::TraitFor::Response::Bar; $INC{'TestApp/TraitFor/Response/Bar.pm'} = __FILE__; use Moose::Role; diff --git a/t/class_traits_CAR_bug.t b/t/class_traits_CAR_bug.t index d160e73..cc57bc1 100644 --- a/t/class_traits_CAR_bug.t +++ b/t/class_traits_CAR_bug.t @@ -11,6 +11,17 @@ BEGIN { } BEGIN { + my %hidden = map { (my $m = "$_.pm") =~ s{::}{/}g; $m => 1 } qw( + Foo + Bar + ); + unshift @INC, sub { + return unless exists $hidden{$_[1]}; + die "Can't locate $_[1] in \@INC (hidden)\n"; + }; +} + +BEGIN { package TestRole; $INC{'TestRole'} = __FILE__; use Moose::Role;