File: unit_core_script_run_options.t

package info (click to toggle)
libcatalyst-perl 5.90132-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,016 kB
  • sloc: perl: 11,061; makefile: 7
file content (40 lines) | stat: -rw-r--r-- 892 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
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;