| 1 | package Outthentic; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | our $VERSION = '0.4.1'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | package main; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use Config::General; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use YAML qw{LoadFile}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use JSON; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use Cwd; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use File::Temp qw/ tempfile /; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Outthentic::Story; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use Term::ANSIColor; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 1 | ▶ | use Hash::Merge qw{merge}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ▶ | use Time::localtime; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 1 | ▶ | use Capture::Tiny; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | Hash::Merge::specify_behavior( | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 'SCALAR' => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 0 | ▶ | 'SCALAR' => sub { $_[1] }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | ▶ | 'ARRAY' => sub { [ $_[0], @{$_[1]} ] }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 0 | ▶ | 'HASH' => sub { $_[1] }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 'ARRAY' => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 0 | ▶ | 'SCALAR' => sub { $_[1] }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | ▶ | 'ARRAY' => sub { [ @{$_[1]} ] }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | ▶ | 'HASH' => sub { $_[1] }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 'HASH' => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | ▶ | 'SCALAR' => sub { $_[1] }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 0 | ▶ | 'ARRAY' => sub { [ values %{$_[0]}, @{$_[1]} ] }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | ▶ | 'HASH' => sub { Hash::Merge::_merge_hashes( $_[0], $_[1] ) }, | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | 'Strun', | |||||||||||||||||||||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | my $config_data; | |||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | our $STATUS = 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | sub execute_cmd { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $cmd = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_cmd: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | note("execute cmd: $cmd") if debug_mod2(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | (system($cmd) == 0); | |||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | sub execute_cmd2 { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | my $cmd = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
execute_cmd2: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | my $out; | |||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 0 | my $format = get_prop('format'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 0 | ▶ | note("execute scenario: $cmd") if debug_mod2(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $stdout; my $stderr; my $exit; | |||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | if ($format eq 'production'){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | ▶ | ( $stdout, $stderr, $exit) = Capture::Tiny::capture { system( $cmd ) }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } else{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | ( $stdout, $stderr, $exit) = Capture::Tiny::tee { system( $cmd ) }; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | return ($exit >> 8,$stdout.$stderr); | |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | sub config { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | ▶ | $config_data | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
config: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | sub dump_config { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ▶ | my $json = JSON->new->pretty; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dump_config: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | print $json->encode(config()); | |||||||||||||||||||||||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | sub nocolor { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | ▶ | get_prop('nocolor') | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
nocolor: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | sub populate_config { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | unless (config()){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
populate_config: not called CC=46 SCAR=76.8
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | if (get_prop('ini_file_path') and -f get_prop('ini_file_path') ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
Condition0%0/3
get_prop("ini_file_path") and -f get_prop("ini_file_path")
MC/DC0%0/2
get_prop("ini_file_path") and -f get_prop("ini_file_path")
get_prop("ini_file_path")
-f get_prop("ini_file_path")
Truth table0%0/3
A and B
A= get_prop("ini_file_path")B= -f get_prop("ini_file_path")
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my $path = get_prop('ini_file_path'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | my %c = Config::General->new( | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | -InterPolateVars => 1 , | ||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | -InterPolateEnv => 1 , | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | -ConfigFile => $path | ||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | )->getall or confess "file $path is not valid config file"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $config_data = {%c}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ▶ | }elsif(get_prop('yaml_file_path') and -f get_prop('yaml_file_path')){ | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
get_prop("yaml_file_path") and -f get_prop("yaml_file_path")
MC/DC0%0/2
get_prop("yaml_file_path") and -f get_prop("yaml_file_path")
get_prop("yaml_file_path")
-f get_prop("yaml_file_path")
Truth table0%0/3
A and B
A= get_prop("yaml_file_path")B= -f get_prop("yaml_file_path")
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $path = get_prop('yaml_file_path'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | ($config_data) = LoadFile($path); | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ▶ | }elsif ( get_prop('json_file_path') and -f get_prop('json_file_path') ){ | |||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
get_prop("json_file_path") and -f get_prop("json_file_path")
MC/DC0%0/2
get_prop("json_file_path") and -f get_prop("json_file_path")
get_prop("json_file_path")
-f get_prop("json_file_path")
Truth table0%0/3
A and B
A= get_prop("json_file_path")B= -f get_prop("json_file_path")
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $path = get_prop('json_file_path'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | open DATA, $path or confess "can't open file $path to read: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $json_str = join "", <DATA>; | |||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | close DATA; | |||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $config_data = from_json($json_str); | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | }elsif ( -f 'suite.ini' ){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my $path = 'suite.ini'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | my %c = Config::General->new( | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | -InterPolateVars => 1 , | ||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | -InterPolateEnv => 1 , | ||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | -ConfigFile => $path | ||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | )->getall or confess "file $path is not valid config file"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $config_data = {%c}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 116 | }elsif ( -f 'suite.yaml'){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | my $path = 'suite.yaml'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ($config_data) = LoadFile($path); | |||||||||||||||||||||||||||||||||||||||||||||||
| 119 | }elsif ( -f 'suite.json'){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | my $path = 'suite.json'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | ▶ | open DATA, $path or confess "can't open file $path to read: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | my $json_str = join "", <DATA>; | |||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | close DATA; | |||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $config_data = from_json($json_str); | |||||||||||||||||||||||||||||||||||||||||||||||
| 125 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $config_data = { }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | my $default_config; | |||||||||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | if ( -f 'suite.ini' ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | my $path = 'suite.ini'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | my %c = Config::General->new( | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | -InterPolateVars => 1 , | ||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | -InterPolateEnv => 1 , | ||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | -ConfigFile => $path | ||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | )->getall or confess "file $path is not valid config file"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | $default_config = {%c}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 140 | }elsif ( -f 'suite.yaml'){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | my $path = 'suite.yaml'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ($default_config) = LoadFile($path); | |||||||||||||||||||||||||||||||||||||||||||||||
| 143 | }elsif ( -f 'suite.json'){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | my $path = 'suite.json'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | open DATA, $path or confess "can't open file $path to read: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | my $json_str = join "", <DATA>; | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | close DATA; | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $default_config = from_json($json_str); | |||||||||||||||||||||||||||||||||||||||||||||||
| 149 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | $default_config = { }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | my @runtime_params; | |||||||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | if (my $args_file = get_prop('args_file') ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | open ARGS_FILE, $args_file or die "can't open file $args_file to read: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | while (my $l = <ARGS_FILE>) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | chomp $l; | |||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | next unless $l=~/\S/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | push @runtime_params, $l; | |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | close ARGS_FILE; | |||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | @runtime_params = split /:::/, get_prop('runtime_params'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | my $config_res = merge( $default_config, $config_data ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | PARAM: for my $rp (@runtime_params){ | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $value; | |||||||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | if ($rp=~s/=(.*)//){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | $value = $1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 176 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | next PARAM; | |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my @pathes = split /\./, $rp; | |||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | my $last_path = pop @pathes; | |||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | my $root = $config_res; | |||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | for my $path (@pathes){ | |||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | ▶ | next PARAM unless defined $root->{$path}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | $root = $root->{$path}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 187 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $root->{$last_path} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | open CONFIG, '>', story_cache_dir().'/config.json' | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | or die "can't open to write file ".story_cache_dir()."/config.json : $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $json = JSON->new(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | print CONFIG $json->encode($config_res); | |||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | close CONFIG; | |||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | ▶ | note("configuration populated and saved to ".story_cache_dir()."/config.json") if debug_mod12; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | # populating cli_args from config_data{args} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 0 | ▶ | unless (get_prop('cli_args')){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | if ($config_res->{'args'} and ref($config_res->{'args'}) eq 'ARRAY'){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$config_res->{"args"} and ref $config_res->{"args"} eq "ARRAY"
MC/DC0%0/2
$config_res->{"args"} and ref $config_res->{"args"} eq "ARRAY"
$config_res->{"args"}
ref $config_res->{"args"} eq "ARRAY"
Truth table0%0/3
A and B
A= $config_res->{"args"}B= ref $config_res->{"args"} eq "ARRAY"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | note("populating cli args from args in configuration data") if debug_mod12; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my @cli_args; | |||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | for my $item (@{$config_res->{'args'}}){ | |||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | if (! ref $item){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | push @cli_args, $item; | |||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } elsif(ref $item eq 'HASH'){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | for my $k ( keys %{$item}){ | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | my $k1 = $k; | |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ($k1=~s/^~//){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | push @cli_args, '-'.$k1, $item->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 212 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | push @cli_args, '--'.$k1, $item->{$k}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | } elsif(ref $item eq 'ARRAY'){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | push @cli_args, map { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | my $v = $_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | $v=~s/^~// ? '-'.$v : '--'.$v; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | } @{$item}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 221 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | note("cli args set to: ".(join ' ', @cli_args)) if debug_mod12; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | set_prop('cli_args', join ' ', @cli_args ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | ▶ | open CLI_ARGS, '>', story_cache_dir().'/cli_args' | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | or die "can't open to write file ".story_cache_dir()."/cli_args : $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | print CLI_ARGS get_prop('cli_args'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | close CLI_ARGS; | |||||||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | note("cli args populated and saved to ".story_cache_dir()."/cli_args") if debug_mod12; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # it should be done once | ||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | # and it always true | ||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | # as populate_config() reach this lines | ||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | # only once, when config is really populated | ||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if ( get_prop('cwd') ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | unless (chdir(get_prop('cwd'))){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | $STATUS = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | die "can't change working directory to: ".(get_prop('cwd'))." : $!"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | return $config_data = $config_res; | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | return $config_data; | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | sub print_story_header { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | ▶ | my $task_name = get_prop('task_name'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_story_header: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my $format = get_prop('format'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $data; | |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | if ($format eq 'production') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | $data = timestamp().' : '.($task_name || '').' '.(short_story_name($task_name)) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$task_name || ''
MC/DC0%0/1
$task_name || ''
$task_name
Truth table0%0/2
A
A= $task_name
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | } elsif ($format ne 'concise') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | ▶ | $data = timestamp().' : '.($task_name || '' ).' '.(nocolor() ? short_story_name($task_name) : colored(['yellow'],short_story_name($task_name))) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$task_name || ''
MC/DC0%0/1
$task_name || ''
$task_name
Truth table0%0/2
A
A= $task_name
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | ▶ | if ($format eq 'production'){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | note($data,1) | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | note($data) | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | sub run_story_file { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | return get_prop('stdout') if defined get_prop('stdout'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_story_file: not called CC=19 SCAR=59.4
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | set_prop('has_scenario',1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $format = get_prop('format'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $story_dir = get_prop('story_dir'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | ▶ | if ( get_stdout() ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | print_story_header(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | note("stdout is already set") if debug_mod12; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | unless ($format eq 'production') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | for my $l (split /\n/, get_stdout()){ | |||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | note($l); | |||||||||||||||||||||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | set_prop( stdout => get_stdout() ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | set_prop( scenario_status => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | Outthentic::Story::Stat->set_scenario_status(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | Outthentic::Story::Stat->set_stdout(get_stdout()); | |||||||||||||||||||||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | my $story_command; | |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ( -f "$story_dir/story.pl" ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | ▶ | if (-f project_root_dir()."/cpanfile" ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ( $^O =~ 'MSWin' ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | $story_command = "set PATH=%PATH%;".project_root_dir()."/local/bin/ && perl -I ".story_cache_dir(). | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | " -I ".project_root_dir()."/local/lib/perl5 -I".project_root_dir()."/lib " ."-MOutthentic::Glue::Perl $story_dir/story.pl"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $story_command = "PATH=\$PATH:".project_root_dir()."/local/bin/ perl -I ".story_cache_dir(). | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | " -I ".project_root_dir()."/local/lib/perl5 -I".project_root_dir()."/lib " ."-MOutthentic::Glue::Perl $story_dir/story.pl"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $story_command = "perl -I ".story_cache_dir()." -I ".project_root_dir()."/lib"." -MOutthentic::Glue::Perl $story_dir/story.pl"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 0 | print_story_header(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 319 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | } elsif(-f "$story_dir/story.rb") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | my $story_file = "$story_dir/story.rb"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my $ruby_lib_dir = File::ShareDir::dist_dir('Outthentic'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | if (-f project_root_dir()."/Gemfile" ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $story_command = "cd ".project_root_dir()." && bundle exec ruby -I $ruby_lib_dir -r outthentic -I ".story_cache_dir()." $story_file"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 328 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | $story_command = "ruby -I $ruby_lib_dir -r outthentic -I ".story_cache_dir()." $story_file"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | print_story_header(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | }elsif(-f "$story_dir/story.py") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my $python_lib_dir = File::ShareDir::dist_dir('Outthentic'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | $story_command = "PYTHONPATH=\$PYTHONPATH:".(story_cache_dir()). | |||||||||||||||||||||||||||||||||||||||||||||||
| 338 | ":$python_lib_dir python $story_dir/story.py"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | print_story_header(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | } elsif(-f "$story_dir/story.bash") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | my $bash_lib_dir = File::ShareDir::dist_dir('Outthentic'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $story_command = "bash -c 'source ".story_cache_dir()."/glue.bash"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $story_command.= " && source ".$bash_lib_dir."/outthentic.bash"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | $story_command.= " && source $story_dir/story.bash'"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | print_story_header(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | # print "empty story\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | print "run story: $story_command ...\n" if debug_mod12; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | my ($ex_code, $out) = execute_cmd2($story_command); | |||||||||||||||||||||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | ▶ | print_story_messages($out) if $format eq 'production'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if ($ex_code == 0) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | outh_ok(1, "scenario succeeded" ) unless $format eq 'production'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | set_prop( scenario_status => 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | Outthentic::Story::Stat->set_scenario_status(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | Outthentic::Story::Stat->set_stdout($out); | |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | }elsif(ignore_story_err()){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | outh_ok(1, "scenario failed, still continue due to `ignore_story_err' is set"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | set_prop( scenario_status => 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | Outthentic::Story::Stat->set_scenario_status(2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | Outthentic::Story::Stat->set_stdout($out); | |||||||||||||||||||||||||||||||||||||||||||||||
| 375 | }else{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 0 | ▶ | if ( $format eq 'production'){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | print "$out"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | outh_ok(0, "scenario succeeded", $ex_code); | |||||||||||||||||||||||||||||||||||||||||||||||
| 379 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | outh_ok(0, "scenario succeeded", $ex_code); | |||||||||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | set_prop( scenario_status => 0 ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | Outthentic::Story::Stat->set_scenario_status(0); | |||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | Outthentic::Story::Stat->set_stdout($out); | |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | Outthentic::Story::Stat->set_status(0); | |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | set_prop( stdout => $out ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | return get_prop('stdout'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | sub header { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | my $project = project_root_dir(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
header: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $story = get_prop('story'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $story_type = get_prop('story_type'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $story_file = get_prop('story_file'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $debug = get_prop('debug'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my $ignore_story_err = ignore_story_err(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | note("project: $project"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | note("story: $story"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | note("story_type: $story_type"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | note("debug: $debug"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | note("ignore story errors: $ignore_story_err"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | sub run_and_check { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | my $story_check_file = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
run_and_check: not called CC=17 SCAR=57.2
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | my $format = get_prop('format'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | header() if debug_mod2(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | dsl()->{debug_mod} = get_prop('debug'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | dsl()->{match_l} = get_prop('match_l'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | eval { dsl()->{output} = run_story_file() }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | if ($@) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $STATUS = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 0 | die "story run error: $@"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 431 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | ▶ | return unless get_prop('scenario_status'); # we don't run checks for failed scenarios | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | return unless $story_check_file; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | ▶ | return unless -s $story_check_file; # don't run check when check file is empty | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | ▶ | open my $fh, $story_check_file or confess $!; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | my $check_list = join "", <$fh>; close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | dsl()->validate($check_list) | |||||||||||||||||||||||||||||||||||||||||||||||
| 442 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $err = $@; | |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | my $check_fail=0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | for my $r ( @{dsl()->results}){ | |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | note($r->{message}) if $r->{type} eq 'debug'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | ▶ | if ($r->{type} eq 'check_expression' ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | Outthentic::Story::Stat->add_check_stat($r); | |||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | ▶ | $check_fail=1 unless $r->{status}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | ▶ | if ($format eq 'production'){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | outh_ok($r->{status}, $r->{message}) unless $r->{status}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | outh_ok($r->{status}, $r->{message}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | Outthentic::Story::Stat->set_status(0) unless $r->{status}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | if ($err) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | $STATUS = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | die "validator error: $err"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | ▶ | if ($format eq 'production' and $check_fail) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$format eq "production" and $check_fail
MC/DC0%0/2
$format eq "production" and $check_fail
$format eq "production"
$check_fail
Truth table0%0/3
A and B
A= $format eq "production"B= $check_fail
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | print get_prop("stdout"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | sub print_story_messages { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | my $out = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_story_messages: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | print " [msg] " if $out=~/outthentic_message/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | my @m = ($out=~/outthentic_message:\s+(.*)/g); | |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | print join " ", @m; | |||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | sub outh_ok { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | my $status = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
outh_ok: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | my $message = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | my $exit_code = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | my $format = get_prop('format'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 0 | ▶ | if ($format ne 'concise'){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | if ($status) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | print nocolor() ? "ok\t$message\n" : colored(['green'],"ok\t$message")."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | ▶ | print nocolor() ? "not ok\t$message\n" : colored(['red'], "not ok\t$message")."\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | if ($status == 0 and $STATUS != 0 ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$status == 0 and $main::STATUS != 0
MC/DC0%0/2
$status == 0 and $main::STATUS != 0
$status == 0
$main::STATUS != 0
Truth table0%0/3
A and B
A= $status == 0B= $main::STATUS != 0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | $STATUS = ($exit_code == 1 ) ? -1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | sub note { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | my $message = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
note: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my $no_new_line = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | binmode(STDOUT, ":utf8"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | print $message; | |||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | ▶ | print "\n" unless $no_new_line; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | sub print_meta { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | open META, get_prop('story_dir')."/meta.txt" or die $!; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
print_meta: not called CC=4 SCAR=30.0
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | my $task_name = get_prop('task_name'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | #note( ( nocolor() ? short_story_name($task_name) : colored( ['yellow'], short_story_name($task_name) ) )); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | while (my $i = <META>){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | chomp $i; | |||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $i='@ '.$i; | |||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | note( nocolor() ? $i : colored( ['magenta'], "$i" )); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | close META; | |||||||||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | sub short_story_name { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | my $task_name = shift; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
short_story_name: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | my $story_dir = get_prop('story_dir'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | my $cwd_size = scalar(split /\//, get_prop('project_root_dir')); | |||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | my $short_story_dir; | |||||||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | my $i; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | for my $l (split /\//, $story_dir){ | |||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | $short_story_dir.=$l."/" unless $i++ < $cwd_size; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $story_vars = story_vars_pretty(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | ▶ | $short_story_dir ||= "/"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$short_story_dir ||= "/"
MC/DC0%0/1
$short_story_dir ||= "/"
$short_story_dir
Truth table0%0/2
A
A= $short_story_dir
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | my @ret; | |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 0 | ▶ | push @ret, "[path] $short_story_dir" if $short_story_dir; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | ▶ | push @ret, "[params] $story_vars" if $story_vars; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | join " ", @ret; | |||||||||||||||||||||||||||||||||||||||||||||||
| 558 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | sub timestamp { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | sprintf '%02d-%02d-%02d %02d:%02d:%02d', | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timestamp: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | localtime->year()+1900, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | localtime->mon()+1, localtime->mday, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | localtime->hour, localtime->min, localtime->sec; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | END { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | #print "STATUS: $STATUS\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | if ($STATUS == 1){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | exit(0); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } elsif($STATUS == -1){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | exit(1); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | } else{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | exit(2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||