[Catalyst-commits] r12203 - in Catalyst-Devel/1.00/trunk: . lib/Catalyst t

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Sun Dec 6 12:14:46 GMT 2009


Author: t0m
Date: 2009-12-06 12:14:46 +0000 (Sun, 06 Dec 2009)
New Revision: 12203

Modified:
   Catalyst-Devel/1.00/trunk/
   Catalyst-Devel/1.00/trunk/Makefile.PL
   Catalyst-Devel/1.00/trunk/lib/Catalyst/Helper.pm
   Catalyst-Devel/1.00/trunk/t/generated_app.t
Log:
 r12228 at t0mlaptop (orig r12193):  autarch | 2009-12-05 22:30:42 +0000
 branch to fix generated_app.t
 r12229 at t0mlaptop (orig r12194):  autarch | 2009-12-05 22:32:19 +0000
 Fixes for generated_app.t so it doesn't rely on finding catalyst.pl in the current path, and so that it always uses the right share dir
 r12237 at t0mlaptop (orig r12202):  t0m | 2009-12-06 12:13:01 +0000
 Force the optional test dep in author mode



Property changes on: Catalyst-Devel/1.00/trunk
___________________________________________________________________
Name: svk:merge
   - 4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Devel/1.00/branches/helper_refactor:12110
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Devel:6899
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Helper:4258
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Devel-helper-refactor:11494
   + 4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Devel/1.00/branches/generated_app-fix:12202
4ad37cd2-5fec-0310-835f-b3785c72a374:/Catalyst-Devel/1.00/branches/helper_refactor:12110
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Devel:6899
4ad37cd2-5fec-0310-835f-b3785c72a374:/trunk/Catalyst-Helper:4258
6d45476b-5895-46b8-b13a-8b969fa34c98:/local/Catalyst-Devel-helper-refactor:11494

Modified: Catalyst-Devel/1.00/trunk/Makefile.PL
===================================================================
--- Catalyst-Devel/1.00/trunk/Makefile.PL	2009-12-06 12:13:01 UTC (rev 12202)
+++ Catalyst-Devel/1.00/trunk/Makefile.PL	2009-12-06 12:14:46 UTC (rev 12203)
@@ -1,4 +1,7 @@
+use strict;
+use warnings;
 use inc::Module::Install 0.91;
+use Module::Install::AuthorRequires;
 
 name     'Catalyst-Devel';
 all_from 'lib/Catalyst/Devel.pm';
@@ -19,6 +22,8 @@
 requires 'Path::Class' => '0.09';
 requires 'Template'    => '2.14';
 
+author_requires 'IPC::Run3';
+
 test_requires 'Test::More' => '0.94';
 
 install_share 'share';

Modified: Catalyst-Devel/1.00/trunk/lib/Catalyst/Helper.pm
===================================================================
--- Catalyst-Devel/1.00/trunk/lib/Catalyst/Helper.pm	2009-12-06 12:13:01 UTC (rev 12202)
+++ Catalyst-Devel/1.00/trunk/lib/Catalyst/Helper.pm	2009-12-06 12:14:46 UTC (rev 12203)
@@ -35,7 +35,10 @@
 sub get_sharedir_file {
     my ($self, @filename) = @_;
     my $dist_dir;
-    if (-d "inc/.author" && -f "lib/Catalyst/Helper.pm"
+    if (exists $ENV{CATALYST_DEVEL_SHAREDIR}) {
+        $dist_dir = $ENV{CATALYST_DEVEL_SHAREDIR};
+    }
+    elsif (-d "inc/.author" && -f "lib/Catalyst/Helper.pm"
             ) { # Can't use sharedir if we're in a checkout
                 # this feels horrible, better ideas?
         $dist_dir = 'share';

Modified: Catalyst-Devel/1.00/trunk/t/generated_app.t
===================================================================
--- Catalyst-Devel/1.00/trunk/t/generated_app.t	2009-12-06 12:13:01 UTC (rev 12202)
+++ Catalyst-Devel/1.00/trunk/t/generated_app.t	2009-12-06 12:14:46 UTC (rev 12203)
@@ -1,30 +1,46 @@
 use strict;
 use warnings;
 use lib ();
-use File::Temp qw/ tempdir tmpnam /;
+use Cwd qw( abs_path );
+use File::Temp qw/ tempdir /;
 use File::Spec;
 use FindBin qw/$Bin/;
 use Catalyst::Devel;
+use Catalyst::Helper;
+use Test::More;
 
+eval "use IPC::Run3";
+plan skip_all => 'These tests require IPC::Run3' if $@;
+
+my $share_dir = abs_path('share');
+plan skip_all => "No share dir at $share_dir!"
+    unless -d $share_dir;
+
+$ENV{CATALYST_DEVEL_SHAREDIR} = $share_dir;
+
 my $dir = tempdir(CLEANUP => 1);
 my $devnull = File::Spec->devnull;
 
-use Test::More;
-
 diag "Generated app is in $dir";
 
+chdir $dir or die "Cannot chdir to $dir: $!";
+
 {
-    my $exit;
-    if ($^O eq 'MSWin32') {
-      $exit = system("cd $dir & catalyst TestApp > $devnull 2>&1");
-    }
-    else {
-      $exit = system("cd $dir; catalyst.pl TestApp > $devnull 2>&1");
-    }
-    is $exit, 0, 'Exit status ok';
+    open my $fh, '>', $devnull or die "Cannot write to $devnull: $!";
+
+    local *STDOUT = $fh;
+
+    my $helper = Catalyst::Helper->new(
+        {
+            name => 'TestApp',
+        }
+    );
+
+    $helper->mk_app('TestApp');
 }
 
-chdir(File::Spec->catdir($dir, 'TestApp'));
+my $app_dir = File::Spec->catdir($dir, 'TestApp');
+chdir($app_dir) or die "Cannot chdir to $app_dir: $!";
 lib->import(File::Spec->catdir($dir, 'TestApp', 'lib'));
 
 my @files = qw|
@@ -60,9 +76,9 @@
 }
 create_ok($_, 'My' . $_) for qw/Model View Controller/;
 
-is system($^X, 'Makefile.PL'), 0, 'Ran Makefile.PL';
+command_ok( [ $^X, 'Makefile.PL' ] );
 ok -e "Makefile", "Makefile generated";
-is system("make"), 0, 'Run make';
+command_ok( [ 'make' ] );
 
 run_generated_component_tests();
 
@@ -80,9 +96,24 @@
 chdir('/');
 done_testing;
 
+sub command_ok {
+    my $cmd = shift;
+    my $desc = shift;
+
+    my $stdout;
+    my $stderr;
+    run3( $cmd, \undef, \$stdout, \$stderr );
+
+    $desc ||= "Exit status ok for '@{$cmd}'";
+    unless ( is $? >> 8, 0, $desc ) {
+        diag "STDOUT:\n$stdout" if defined $stdout;
+        diag "STDERR:\n$stderr" if defined $stderr;
+    }
+}
+
 sub runperl {
     my $comment = pop @_;
-    is system($^X, '-I', File::Spec->catdir($Bin, '..', 'lib'), @_), 0, $comment;
+    command_ok( [ $^X, '-I', File::Spec->catdir($Bin, '..', 'lib'), @_ ], $comment );
 }
 
 my @generated_component_tests;
@@ -115,5 +146,5 @@
     my ($type, $name) = @_;
     runperl( File::Spec->catdir('script', 'testapp_create.pl'), $type, $name,
         "'script/testapp_create.pl $type $name' ok");
-    test_fn(File::Spec->catdir('t', sprintf("%s_%s.t", $type, $name)));
+    test_fn(File::Spec->catdir('t', sprintf("%s_%s.t", lc $type, $name)));
 }




More information about the Catalyst-commits mailing list