X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=blobdiff_plain;f=t%2Faggregate%2Funit_core_script_run_options.t;fp=t%2Faggregate%2Funit_core_script_run_options.t;h=ff34a2cdc33b65b2f553a52748e6fac1091cc6a8;hp=0000000000000000000000000000000000000000;hb=aee7cdcc0b2b3b7dc672b4b4a31b8c3b7ef3f1f7;hpb=942572d7cd0a89d54b12ddd89de16ddcd19ca077 diff --git a/t/aggregate/unit_core_script_run_options.t b/t/aggregate/unit_core_script_run_options.t new file mode 100644 index 0000000..ff34a2c --- /dev/null +++ b/t/aggregate/unit_core_script_run_options.t @@ -0,0 +1,40 @@ +use strict; +use warnings; +use Test::More; +use FindBin qw/$Bin/; +use IO::Handle; +use Try::Tiny; +use File::Temp qw/ tempfile /; +use lib "$Bin/../lib"; + +use_ok('Catalyst::ScriptRunner'); +use_ok('ScriptTestApp'); + +is ScriptTestApp->run_options, undef; + +my ($fh, $fn) = tempfile(); + +binmode( $fh ); +binmode( STDOUT ); + +local @ARGV = (); +local %ENV; + +my $saved; +open( $saved, '>&'. STDOUT->fileno ) + or croak("Can't dup stdout: $!"); +open( STDOUT, '>&='. $fh->fileno ) + or croak("Can't open stdout: $!"); +local $SIG{__WARN__} = sub {}; # Shut up warnings... +try { Catalyst::ScriptRunner->run('ScriptTestApp', 'CGI'); pass("Ran ok") } +catch { fail "Failed to run $_" }; + +STDOUT->flush + or croak("Can't flush stdout: $!"); + +open( STDOUT, '>&'. fileno($saved) ) + or croak("Can't restore stdout: $!"); + +is_deeply ScriptTestApp->run_options, { argv => [], extra_argv => [] }; + +done_testing;