[Catalyst-commits] r12016 - in Catalyst-Runtime/5.80/branches/better_scripts: . lib/Catalyst lib/Catalyst/Script t/aggregate

t0m at dev.catalyst.perl.org t0m at dev.catalyst.perl.org
Wed Nov 25 22:51:29 GMT 2009


Author: t0m
Date: 2009-11-25 22:51:28 +0000 (Wed, 25 Nov 2009)
New Revision: 12016

Modified:
   Catalyst-Runtime/5.80/branches/better_scripts/TODO.scripts
   Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Test.pm
   Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/ScriptRunner.pm
   Catalyst-Runtime/5.80/branches/better_scripts/t/aggregate/unit_core_script_test.t
Log:
Fix big bug in test

Modified: Catalyst-Runtime/5.80/branches/better_scripts/TODO.scripts
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/TODO.scripts	2009-11-25 22:32:11 UTC (rev 12015)
+++ Catalyst-Runtime/5.80/branches/better_scripts/TODO.scripts	2009-11-25 22:51:28 UTC (rev 12016)
@@ -1,3 +1,2 @@
-* $ARGV[0] has slipped to $ARGV[1] in ::Test
 * Sort out help so that it shows what you fucked up.
 * Fix horrible hacking around MX::Getopt's help display - probably by fixing MX::Getopt.

Modified: Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Test.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Test.pm	2009-11-25 22:32:11 UTC (rev 12015)
+++ Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/Script/Test.pm	2009-11-25 22:51:28 UTC (rev 12016)
@@ -1,5 +1,6 @@
 package Catalyst::Script::Test;
 use Moose;
+use Catalyst::Test ();
 use namespace::autoclean;
 
 with 'Catalyst::ScriptRole';
@@ -9,10 +10,9 @@
 sub run {
     my $self = shift;
 
-    Class::MOP::load_class("Catalyst::Test");
     Catalyst::Test->import($self->application_name);
 
-    print request($ARGV[1])->content  . "\n";
+    print request($ARGV[0])->content  . "\n";
 
 }
 

Modified: Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/ScriptRunner.pm
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/ScriptRunner.pm	2009-11-25 22:32:11 UTC (rev 12015)
+++ Catalyst-Runtime/5.80/branches/better_scripts/lib/Catalyst/ScriptRunner.pm	2009-11-25 22:51:28 UTC (rev 12016)
@@ -11,9 +11,6 @@
 
     lib->import(File::Spec->catdir($FindBin::Bin, '..', 'lib'));
 
-    warn("load $classtoload or Catalyst::Script::$scriptclass");
-
-    # FIXME - Error handling / reporting
     unless ( eval { Class::MOP::load_class($classtoload) } ) {
         warn("Could not load $classtoload - falling back to Catalyst::Script::$scriptclass : $@\n")
             if $@ !~ /Can't locate/;

Modified: Catalyst-Runtime/5.80/branches/better_scripts/t/aggregate/unit_core_script_test.t
===================================================================
--- Catalyst-Runtime/5.80/branches/better_scripts/t/aggregate/unit_core_script_test.t	2009-11-25 22:32:11 UTC (rev 12015)
+++ Catalyst-Runtime/5.80/branches/better_scripts/t/aggregate/unit_core_script_test.t	2009-11-25 22:51:28 UTC (rev 12016)
@@ -11,38 +11,44 @@
 use File::Temp qw/tempfile/;
 use IO::Handle;
 
-my ($fh, $fn) = tempfile();
+is run_test('/'), "root index\n", 'correct content printed';
+is run_test('/moose/get_attribute'), "42\n", 'Correct content printed for non root action';
 
-binmode( $fh );
-binmode( STDOUT );
+done_testing;
 
-{
-    local @ARGV = ('/');
-    my $i;
-    lives_ok {
-        $i = Catalyst::Script::Test->new_with_options(application_name => 'TestApp');
-    } "new_with_options";
-    ok $i;
-    my $saved;
-    open( $saved, '<&'. STDIN->fileno )
-          or croak("Can't dup stdin: $!");
-    open( STDOUT, '>&='. $fh->fileno )
-        or croak("Can't open stdout: $!");
-    eval { $i->run };
-    ok !$@, 'Ran ok';
+sub run_test {
+    my $url = shift;
 
-    STDOUT->flush
-        or croak("Can't flush stdout: $!");
+    my ($fh, $fn) = tempfile();
 
-    open( STDOUT, '>&'. fileno($saved) )
-        or croak("Can't restore stdout: $!");
-}
+    binmode( $fh );
+    binmode( STDOUT );
 
-my $data = do { my $fh; open($fh, '<', $fn) or die $!; local $/; <$fh>; };
-$fh = undef;
-unlink $fn if -r $fn;
+    {
+        local @ARGV = ($url);
+        my $i;
+        lives_ok {
+            $i = Catalyst::Script::Test->new_with_options(application_name => 'TestApp');
+        } "new_with_options";
+        ok $i;
+        my $saved;
+        open( $saved, '<&'. STDIN->fileno )
+              or croak("Can't dup stdin: $!");
+        open( STDOUT, '>&='. $fh->fileno )
+            or croak("Can't open stdout: $!");
+        eval { $i->run };
+        ok !$@, 'Ran ok';
 
-is $data, "root index\n", 'correct content printed';
+        STDOUT->flush
+            or croak("Can't flush stdout: $!");
 
-done_testing;
+        open( STDOUT, '>&'. fileno($saved) )
+            or croak("Can't restore stdout: $!");
+    }
 
+    my $data = do { my $fh; open($fh, '<', $fn) or die $!; local $/; <$fh>; };
+    $fh = undef;
+    unlink $fn if -r $fn;
+
+    return $data;
+}




More information about the Catalyst-commits mailing list