1Test::Script::Run(3)  User Contributed Perl Documentation Test::Script::Run(3)
2
3
4

NAME

6       Test::Script::Run - test the script with run
7

SYNOPSIS

9           use Test::Script::Run;
10           # customized names of bin dirs, default is qw/bin sbin script/;
11           @Test::Script::Run::BIN_DIRS = qw/bin/;
12           run_ok( 'app_name', [ app's args ], 'you_app runs ok' );
13           my ( $return, $stdout, $stderr ) = run_script( 'app_name', [ app's args ] );
14           run_output_matches(
15               'app_name', [app's args],
16               [ 'out line 1', 'out line 2' ],
17               [ 'err line 1', 'err line 2' ],
18               'run_output_matches'
19           );
20           run_output_matches_unordered(
21               'app_name', [ app's args ],
22               [ 'out line 2', 'out line 1' ],
23               [ 'err line 2', 'err line 1' ],
24               'run_output_matches_unordered'
25           );
26

DESCRIPTION

28       This module exports some subs to help test and run scripts in your
29       dist's bin/ directory, if the script path is not absolute.
30
31       Nearly all the essential code is stolen from Prophet::Test, we think
32       subs like those should live below "Test::" namespace, that's why we
33       packed them and created this module.
34

FUNCTIONS

36   run_script($script, $args, $stdout, $stderr)
37       Runs the script $script as a perl script, setting the @INC to the same
38       as our caller.
39
40       $script is the name of the script to be run (such as 'prophet'). $args
41       is a reference to an array of arguments to pass to the script. $stdout
42       and $stderr are both optional; if passed in, they will be passed to
43       IPC::Run3's run3 subroutineA as its $stdout and $stderr args.
44       Otherwise, this subroutine will create scalar references to pass to
45       run3 instead (which are treated as strings for STDOUT/STDERR to be
46       written to).
47
48       Returns run3's return value and, if no $stdout and $stderr were passed
49       in, the STDOUT and STDERR of the script that was run.
50
51   run_ok($script, $args, $msg)
52       Runs the script, checking that it didn't error out.
53
54       $script is the name of the script to be run (e.g. 'prophet'). $args is
55       an optional reference to an array of arguments to pass to the script
56       when it is run. $msg is an optional message to print with the test. If
57       $args is not specified, you can still pass in a $msg.
58
59       Returns nothing of interest.
60
61   run_not_ok($script, $args, $msg)
62       opposite of run_ok
63
64   get_perl_cmd($script, @ARGS)
65       Returns a list suitable for passing to "system", "exec", etc. If you
66       pass $script then we will search upwards for a file bin/$script.
67
68   is_script_output($scriptname \@args, \@stdout_match, \@stderr_match, $msg)
69       Runs $scriptname, checking to see that its output matches.
70
71       $args is an array reference of args to pass to the script.
72       $stdout_match and $stderr_match are references to arrays of expected
73       lines. $msg is a string message to display with the test. $stderr_match
74       and $msg are optional. (As is $stdout_match if for some reason you
75       expect your script to have no output at all. But that would be silly,
76       wouldn't it?)
77
78       Allows regex matches as well as string equality (lines in $stdout_match
79       and $stderr_match may be Regexp objects).
80
81   run_output_matches($script, $args, $exp_stdout, $exp_stderr, $msg)
82       A wrapper around is_script_output that also checks to make sure the
83       test runs without throwing an exception.
84
85   run_output_matches_unordered($script, $args, $exp_stdout, $exp_stderr,
86       $msg)
87       This subroutine has exactly the same functionality as
88       run_output_matches, but doesn't impose a line ordering when comparing
89       the expected and received outputs.
90
91   last_script_stdout
92       return last script's stdout
93
94   last_script_stderr
95       return last script's stderr
96
97   last_script_exit_code
98       return last script's exit code
99

DEPENDENCIES

101       Test::More, Test::Exception, IPC::Run3, File::Basename, File::Spec
102

BUGS AND LIMITATIONS

104       No bugs have been reported.
105

AUTHOR

107       sunnavy  "<sunnavy@bestpractical.com>"
108
110       Copyright 2009 Best Practical Solutions.
111
112       This program is free software; you can redistribute it and/or modify it
113       under the same terms as Perl itself.
114
115
116
117perl v5.12.2                      2010-06-25              Test::Script::Run(3)
Impressum