Fix warnings from ScriptRunner
[catagits/Catalyst-Runtime.git] / t / aggregate / unit_core_script_test.t
CommitLineData
718e995d 1use strict;
2use warnings;
3
4use FindBin qw/$Bin/;
5use lib "$Bin/../lib";
6
7use Test::More;
8use Test::Exception;
9
10use Catalyst::Script::Test;
11use File::Temp qw/tempfile/;
12use IO::Handle;
13
14my ($fh, $fn) = tempfile();
15
16binmode( $fh );
17binmode( STDOUT );
18
19{
20 local @ARGV = ('/');
21 my $i;
22 lives_ok {
23 $i = Catalyst::Script::Test->new_with_options(application_name => 'TestApp');
24 } "new_with_options";
25 ok $i;
26 my $saved;
27 open( $saved, '<&'. STDIN->fileno )
28 or croak("Can't dup stdin: $!");
29 open( STDOUT, '>&='. $fh->fileno )
30 or croak("Can't open stdout: $!");
31 eval { $i->run };
32 ok !$@, 'Ran ok';
33
34 STDOUT->flush
35 or croak("Can't flush stdout: $!");
36
37 open( STDOUT, '>&'. fileno($saved) )
38 or croak("Can't restore stdout: $!");
39}
40
41my $data = do { my $fh; open($fh, '<', $fn) or die $!; local $/; <$fh>; };
42$fh = undef;
43unlink $fn if -r $fn;
44
45is $data, "root index\n", 'correct content printed';
46
47done_testing;
48