script_compiles
[version 1.05]
script_compiles( $script, $test_name );
The "script_compiles" test calls the script with "perl -c script.pl", and checks that it returns without
error.
The path it should be passed is a relative Unix-format script name. This will be localised when running
"perl -c" and if the test fails the local name used will be shown in the diagnostic output.
Note also that the test will be run with the same perl interpreter that is running the test script (and
not with the default system perl). This will also be shown in the diagnostic output on failure.
script_runs
[version 1.05]
script_runs( $script, $test_name );
script_runs( \@script_and_arguments, $test_name );
script_runs( $script, \%options, $test_name );
script_runs( \@script_and_arguments, \%options, $test_name );
The "script_runs" test executes the script with "perl script.pl" and checks that it returns success.
The path it should be passed is a relative unix-format script name. This will be localised when running
"perl -c" and if the test fails the local name used will be shown in the diagnostic output.
The test will be run with the same perl interpreter that is running the test script (and not with the
default system perl). This will also be shown in the diagnostic output on failure.
[version 1.09]
You may pass in options as a hash as the second argument (as of version 1.09).
exit
The expected exit value. The default is to use whatever indicates success on your platform (usually
0).
interpreter_options
[version 1.25]
Array reference of Perl options to be passed to the interpreter. Things like "-w" or "-x" can be
passed this way. This may be either a single string or an array reference.
signal
The expected signal. The default is 0. Use with care! This may not be portable, and is known not
to work on Windows.
stdin
The input to be passed into the script via stdin. The value may be one of
simple scalar
Is considered to be a filename.
scalar reference
In which case the input will be drawn from the data contained in the referenced scalar.
The behavior for any other types is undefined (the current implementation uses Capture::Tiny). Any
already opened stdin will be closed.
stdout
Where to send the standard output to. If you use this option, then the the behavior of the
"script_stdout_" functions below are undefined. The value may be one of
simple scalar
Is considered to be a filename.
scalar reference
In which case the standard output will be places into the referenced scalar
The behavior for any other types is undefined (the current implementation uses Capture::Tiny).
stderr
Same as "stdout" above, except for stderr.
script_fails
[ version 1.28 ]
script_fails $script, { exit => $expected_exit }, $test_name );
script_fails $script, \%options, $test_name;
"script_runs" may be invoked as "script_fails". The exit option is mandatory when used this way. Since
Perl 5.12, "die" usually returns 255, but does not promise to do so. Fatal errors like divide by 0 also
return 255 often so it is not the best error code for a trapped exception. script_runs needs an exit
code it considers success, use "warn; exit;" instead of die.
script_stdout_is
[version 1.09]
script_stdout_is $expected_stdout, $test_name;
Tests if the output to stdout from the previous "script_runs" matches the expected value exactly.
script_stdout_isnt
[version 1.09]
script_stdout_is $expected_stdout, $test_name;
Tests if the output to stdout from the previous "script_runs" does NOT match the expected value exactly.
script_stdout_like
[version 1.09]
script_stdout_like $regex, $test_name;
Tests if the output to stdout from the previous "script_runs" matches the regular expression.
script_stdout_unlike
[version 1.09]
script_stdout_unlike $regex, $test_name;
Tests if the output to stdout from the previous "script_runs" does NOT match the regular expression.
script_stderr_is
[version 1.09]
script_stderr_is $expected_stderr, $test_name;
Tests if the output to stderr from the previous "script_runs" matches the expected value exactly.
script_stderr_isnt
[version 1.09]
script_stderr_is $expected_stderr, $test_name;
Tests if the output to stderr from the previous "script_runs" does NOT match the expected value exactly.
script_stderr_like
[version 1.09]
script_stderr_like $regex, $test_name;
Tests if the output to stderr from the previous "script_runs" matches the regular expression.
script_stderr_unlike
[version 1.09]
script_stderr_unlike $regex, $test_name;
Tests if the output to stderr from the previous "script_runs" does NOT match the regular expression.
program_runs
[version 1.26]
program_runs( $program, $test_name );
program_runs( \@program_and_arguments, $test_name );
program_runs( $program, \%options, $test_name );
program_runs( \@program_and_arguments, \%options, $test_name );
The "program_runs" test executes the given program and checks that it returns success. This function
works like "script_runs" except:
• The path $program or @program_and_arguments is passed as-is to system()
<https://perldoc.perl.org/functions/system.html>. This means "program_runs" can test any program,
not just Perl scripts.
• The %options do not support the "interpreter_options" key.
See File::Spec or Path::Class for routines useful in building pathnames in a cross-platform way.
program_fails
[ version 1.28 ]
program_fails $program, { exit => $expected_exit }, $test_name;
program_fails $program, \%options, $test_name;
"program_runs" may be invoked as "program_fails". "program_fails" needs to know the expected exit value,
so exit becomes a required option.
program_stdout_is
[version 1.26]
program_stdout_is $expected_stdout, $test_name;
Tests if the output to stdout from the previous "program_runs" matches the expected value exactly.
program_stdout_isnt
[version 1.26]
program_stdout_is $expected_stdout, $test_name;
Tests if the output to stdout from the previous "program_runs" does NOT match the expected value exactly.
program_stdout_like
[version 1.26]
program_stdout_like $regex, $test_name;
Tests if the output to stdout from the previous "program_runs" matches the regular expression.
program_stdout_unlike
[version 1.26]
program_stdout_unlike $regex, $test_name;
Tests if the output to stdout from the previous "program_runs" does NOT match the regular expression.
program_stderr_is
[version 1.26]
program_stderr_is $expected_stderr, $test_name;
Tests if the output to stderr from the previous "program_runs" matches the expected value exactly.
program_stderr_isnt
[version 1.26]
program_stderr_is $expected_stderr, $test_name;
Tests if the output to stderr from the previous "program_runs" does NOT match the expected value exactly.
program_stderr_like
[version 1.26]
program_stderr_like $regex, $test_name;
Tests if the output to stderr from the previous "program_runs" matches the regular expression.
program_stderr_unlike
[version 1.26]
program_stderr_unlike $regex, $test_name;
Tests if the output to stderr from the previous "program_runs" does NOT match the regular expression.