| 1 | package TestML1::Setup; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use TestML1::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use TestML1(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 1 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=4 SCAR=19.4
| |||||||||||||||||||||||||||||
| 7 | 1 | for (qw( YAML::XS IO::All Template::Toolkit::Simple )) { | |||||||||||||||||||||||||||
| 8 | 3 | ▶ | if (not $ENV{PERL_ZILD_TEST_000_COMPILE_MODULES}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 9 | 0 | ▶ | eval "use $_; 1" or die "TestML1::Setup requires $_:\n$@"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||
| 11 | } | ||||||||||||||||||||||||||||
| 12 | } | ||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use File::Basename; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 1 | ▶ | use Cwd 'abs_path'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Exporter 'import'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 1 | our @EXPORT = qw( setup ); | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | ▶ | use constant DEFAULT_TESTML_CONF => './t/testml.yaml'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | ▶ | sub setup { | ||||||||||||||||||||||||||
|
Subroutine
setup: not called CC=23 SCAR=63.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 0 | my ($testml_conf) = @_; | |||||||||||||||||||||||||||
| 23 | 0 | ▶ | $testml_conf ||= | ||||||||||||||||||||||||||
|
Condition0%0/5
$testml_conf ||= $ARGV[0] || "./t/testml.yaml"
$ARGV[0] || './t/testml.yaml'
MC/DC0%0/2
$testml_conf ||= $ARGV[0] || "./t/testml.yaml"
$testml_conf
$ARGV[0]
Truth table0%0/3
A ||= B
A= $testml_confB= $ARGV[0]
| |||||||||||||||||||||||||||||
| 24 | $ARGV[0] || | ||||||||||||||||||||||||||||
| 25 | DEFAULT_TESTML_CONF; | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | die "TestML1 conf file '$testml_conf' not found" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | unless -f $testml_conf; | ||||||||||||||||||||||||||||
| 28 | 0 | ▶ | die "TestML1 conf file must be .yaml" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | unless $testml_conf =~ /\.ya?ml$/; | ||||||||||||||||||||||||||||
| 30 | # File paths are relative to the yaml file location | ||||||||||||||||||||||||||||
| 31 | 0 | my $base = File::Basename::dirname($testml_conf); | |||||||||||||||||||||||||||
| 32 | 0 | my $conf = YAML::XS::LoadFile($testml_conf); | |||||||||||||||||||||||||||
| 33 | my $source = $conf->{source_testml_dir} | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | or die "`testml_setup` requires 'source_testml_dir' key in '$testml_conf'"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | my $target = $conf->{local_testml_dir} | ||||||||||||||||||||||||||||
| 36 | 0 | ▶ | or die "`testml_setup` requires 'local_testml_dir' key in '$testml_conf'"; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | ▶ | my $tests = $conf->{test_file_dir} || '.'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{'test_file_dir'} || '.'
MC/DC0%0/1
$conf->{'test_file_dir'} || '.'
$conf->{'test_file_dir'}
Truth table0%0/2
A
A= $conf->{'test_file_dir'}
| |||||||||||||||||||||||||||||
| 38 | 0 | $source = abs_path("$base/$source"); | |||||||||||||||||||||||||||
| 39 | 0 | $target = abs_path("$base/$target"); | |||||||||||||||||||||||||||
| 40 | 0 | $tests = abs_path("$base/$tests"); | |||||||||||||||||||||||||||
| 41 | 0 | ▶ | die "'$source' directory does not exist" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | unless -e $source; | ||||||||||||||||||||||||||||
| 43 | 0 | ▶ | mkdir $target unless -d $target; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | mkdir $tests unless -d $tests; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | 0 | ▶ | my $template = $conf->{test_file_template} || ''; | ||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{'test_file_template'} || ''
MC/DC0%0/1
$conf->{'test_file_template'} || ''
$conf->{'test_file_template'}
Truth table0%0/2
A
A= $conf->{'test_file_template'}
| |||||||||||||||||||||||||||||
| 46 | 0 | ▶ | my $skip = $conf->{exclude_testml_files} || []; | ||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{'exclude_testml_files'} || []
MC/DC0%0/1
$conf->{'exclude_testml_files'} || []
$conf->{'exclude_testml_files'}
Truth table0%0/2
A
A= $conf->{'exclude_testml_files'}
| |||||||||||||||||||||||||||||
| 47 | my $files = $conf->{include_testml_files} || | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | [map $_->filename, grep {"$_" =~ /\.tml$/} io($source)->all_files]; | ||||||||||||||||||||||||||
|
Condition0%0/2
$conf->{'include_testml_files'} || [map($_->filename, grep({"$_" =~ /\.tml$/;} io($source)->all_files))]
MC/DC0%0/1
$conf->{'include_testml_files'} || [map($_->filename, grep({"$_" =~ /\.tml$/;} io($source)->all_files))]
$conf->{'include_testml_files'}
Truth table0%0/2
A
A= $conf->{'include_testml_files'}
| |||||||||||||||||||||||||||||
| 49 | 0 | for my $file (sort @$files) { | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | next if grep {$_ eq $file} @$skip; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | my $s = "$source/$file"; | |||||||||||||||||||||||||||
| 52 | 0 | my $t = "$target/$file"; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | if (not -f $t or io($s)->all ne io($t)->all) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -f $t or io($s)->all ne io($t)->all
MC/DC0%0/2
not -f $t or io($s)->all ne io($t)->all
not -f $t
io($s)->all ne io($t)->all
Truth table0%0/3
not(A) or B
A= not -f $tB= io($s)->all ne io($t)->all
| |||||||||||||||||||||||||||||
| 54 | 0 | print "Copying ${\ relative_path($s)} to ${\ relative_path($t)}\n"; | |||||||||||||||||||||||||||
| 55 | 0 | io($t)->print(io($s)->all); | |||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||
| 57 | 0 | ▶ | if ($template) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | 0 | (my $test = $file) =~ s/\.tml$/.t/; | |||||||||||||||||||||||||||
| 59 | $test = $conf->{test_file_prefix} . $test | ||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if $conf->{test_file_prefix}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | $test = abs_path "$tests/$test"; | |||||||||||||||||||||||||||
| 62 | 0 | my ($volume, $directories, $file) = | |||||||||||||||||||||||||||
| 63 | File::Spec->splitpath(relative_path($t, $base)); | ||||||||||||||||||||||||||||
| 64 | 0 | my $path = [ | |||||||||||||||||||||||||||
| 65 | grep $_, File::Spec->splitdir($directories), $file | ||||||||||||||||||||||||||||
| 66 | ]; | ||||||||||||||||||||||||||||
| 67 | 0 | my $hash = { | |||||||||||||||||||||||||||
| 68 | testml_setup_comment => testml_setup_comment($testml_conf), | ||||||||||||||||||||||||||||
| 69 | file => relative_path($t, $base), | ||||||||||||||||||||||||||||
| 70 | path => $path, | ||||||||||||||||||||||||||||
| 71 | }; | ||||||||||||||||||||||||||||
| 72 | 0 | my $code = tt->data($hash)->render(\$template); | |||||||||||||||||||||||||||
| 73 | 0 | ▶ | if (not -f $test or $code ne io($test)->all) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -f $test or $code ne io($test)->all
MC/DC0%0/2
not -f $test or $code ne io($test)->all
not -f $test
$code ne io($test)->all
Truth table0%0/3
not(A) or B
A= not -f $testB= $code ne io($test)->all
| |||||||||||||||||||||||||||||
| 74 | 0 | ▶ | my $action = -f $test ? 'Updating' : 'Creating'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 0 | print "$action test file '${\ relative_path($test)}'\n"; | |||||||||||||||||||||||||||
| 76 | 0 | io($test)->print($code); | |||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||
| 78 | } | ||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub relative_path { | ||||||||||||||||||||||||||
|
Subroutine
relative_path: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | 0 | my ($path, $base) = @_; | |||||||||||||||||||||||||||
| 84 | 0 | ▶ | $base ||= '.'; | ||||||||||||||||||||||||||
|
Condition0%0/2
$base ||= "."
MC/DC0%0/1
$base ||= "."
$base
Truth table0%0/2
A
A= $base
| |||||||||||||||||||||||||||||
| 85 | 0 | $base = abs_path($base); | |||||||||||||||||||||||||||
| 86 | 0 | File::Spec->abs2rel($path, $base); | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub testml_setup_comment { | ||||||||||||||||||||||||||
|
Subroutine
testml_setup_comment: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 0 | my ($testml_conf) = @_; | |||||||||||||||||||||||||||
| 91 | 0 | <<"..."; | |||||||||||||||||||||||||||
| 92 | # DO NOT EDIT | ||||||||||||||||||||||||||||
| 93 | # | ||||||||||||||||||||||||||||
| 94 | # This file was generated by TestML1::Setup ($TestML1::VERSION) | ||||||||||||||||||||||||||||
| 95 | # | ||||||||||||||||||||||||||||
| 96 | # > perl -MTestML1::Setup -e setup $testml_conf | ||||||||||||||||||||||||||||
| 97 | ... | ||||||||||||||||||||||||||||
| 98 | } | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | 1 | 1; | |||||||||||||||||||||||||||