| 1 | package Poet::t::Script; | ||||||||||
| 2 | 1 | $Poet::t::Script::VERSION = '0.16'; | |||||||||
| 3 | 1 | ▶ | use Test::Class::Most parent => 'Poet::Test::Class'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use Capture::Tiny qw(capture); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use Cwd qw(realpath); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use YAML::XS; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Poet::Tools qw(dirname mkpath perl_executable tempdir_simple write_file); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | my $script_template; | |||||||||
| 10 | |||||||||||
| 11 | 1 | ▶ | sub test_script : Tests { | ||||||||
|
Subroutine
test_script: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||
| 12 | 1 | my $self = shift; | |||||||||
| 13 | 1 | my $root_dir = $self->temp_env_dir(); | |||||||||
| 14 | |||||||||||
| 15 | 1 | $self->write_conf_file( "$root_dir/conf/global/server.cfg", { 'foo.bar' => 42 } ); | |||||||||
| 16 | |||||||||||
| 17 | 1 | my $script = "$root_dir/bin/foo/bar.pl"; | |||||||||
| 18 | 1 | mkpath( dirname($script), 0, 0775 ); | |||||||||
| 19 | 1 | my $env_lib_dir = realpath("lib"); | |||||||||
| 20 | 1 | write_file( $script, sprintf( $script_template, perl_executable(), $env_lib_dir ) ); | |||||||||
| 21 | 1 | chmod( 0775, $script ); | |||||||||
| 22 | 1 | ▶ | my ( $stdout, $stderr ) = capture { system($script) }; | ||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||
| 23 | 1 | ▶ | ok( !$stderr, "no stderr" . ( defined($stderr) ? " - $stderr" : "" ) ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | |||||||||||
| 25 | 1 | my $result = Load($stdout); | |||||||||
| 26 | 1 | is_deeply( $result, [ $root_dir, "$root_dir/lib", "$root_dir/lib", 42 ] ); | |||||||||
| 27 | 1 | ▶ | } | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 28 | |||||||||||
| 29 | 1 | $script_template = '#!%s | |||||||||
| 30 | use lib qw(%s); | ||||||||||
| 31 | use Poet::Script qw($conf $poet); | ||||||||||
| 32 | use YAML::XS; | ||||||||||
| 33 | |||||||||||
| 34 | print Dump([$poet->root_dir, $poet->lib_dir, $INC[0], $conf->get("foo.bar")]); | ||||||||||
| 35 | '; | ||||||||||
| 36 | |||||||||||
| 37 | 1 | 1; | |||||||||