From: Tomas Doran Date: Tue, 1 Dec 2009 02:47:08 +0000 (+0000) Subject: Fix bug with generated component classes and an issue with the test X-Git-Tag: 1.21_01~1^2~6 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Devel.git;a=commitdiff_plain;h=41cebeb1e1e47c8fbab0b112342baaeaea232061 Fix bug with generated component classes and an issue with the test --- diff --git a/share/t/comptest.tt b/share/t/comptest.tt index 00800f8..ca044c9 100644 --- a/share/t/comptest.tt +++ b/share/t/comptest.tt @@ -13,7 +13,7 @@ ok( my $mech = Test::WWW::Mechanize::Catalyst->new, 'Created mech object' ); $mech->get_ok( 'http://localhost[% uri %]' ); [% ELSE %]use Test::More tests => 3; -BEGIN { use_ok 'Catalyst::Test', '[% name %]' } +BEGIN { use_ok 'Catalyst::Test', '[% app %]' } BEGIN { use_ok '[% class %]' } ok( request('[% uri %]')->is_success, 'Request should succeed' ); diff --git a/t/generated_app.t b/t/generated_app.t index 46e708c..2a46078 100644 --- a/t/generated_app.t +++ b/t/generated_app.t @@ -64,6 +64,8 @@ is system($^X, 'Makefile.PL'), 0, 'Ran Makefile.PL'; ok -e "Makefile", "Makefile generated"; is system("make"), 0, 'Run make'; +run_generated_component_tests(); + my $server_script = do { open(my $fh, '<', File::Spec->catdir(qw/script testapp_server.pl/)) or fail $!; local $/; @@ -83,10 +85,12 @@ sub runperl { is system($^X, '-I', File::Spec->catdir($Bin, '..', 'lib'), @_), 0, $comment; } +my @generated_component_tests; + sub test_fn { local $ENV{TEST_POD} = 1; local $ENV{CATALYST_DEBUG} = 0; - + my $fn = shift; ok -r $fn, "Have $fn in generated app"; if ($fn =~ /script/) { @@ -95,7 +99,13 @@ sub test_fn { if ($fn =~ /\.p[ml]$/) { runperl( '-c', $fn, "$fn compiles" ); } - if ($fn =~ /\.t$/) { + # Save these till later as Catalyst::Test will only be loaded once :-/ + push @generated_component_tests, $fn + if $fn =~ /\.t$/; +} + +sub run_generated_component_tests { + foreach my $fn (@generated_component_tests) { subtest "Generated app test: $fn", sub { require $fn; };