Branch Coverage

blib/lib/NCustom.pm
Criterion Covered Total %
branch 315 552 57.0


line true false branch
117 0 1 unless ok -d $input
119 0 1 unless -d $input
124 0 1 unless use_ok 'NCustom', ':all'
140 0 19 if $_STDOUT_
141 1 18 if $_STDERR_
155 0 1 unless is $NCustom::Config{'test_data1'}, 'global_value'
157 0 1 unless is $NCustom::Config{'test_data2'}, 'global_value'
159 0 1 unless is $NCustom::Config{'save_dir'}, "$output/.ncustom/save"
165 0 1 unless is $NCustom::Config{'test_data1'}, 'global_value'
171 0 1 unless is $NCustom::Config{'test_data2'}, 'local_value'
184 0 1 unless ok grep(/get_url $target_url $target_dir/, @lines) > 0
196 0 1 unless is $NCustom::Config{'test_data1'}, 'global_value'
198 1 0 unless is $NCustom::Config{'test_data2'}, 'global_value'
246 0 1 unless ok -d "$output/.ncustom/save/all"
248 0 1 unless ok -d "$output/.ncustom/tmp"
250 0 1 unless -d "$output/.ncustom/save/all"
259 18 1 unless (-d $NCustom::Config{'save_dir'})
263 18 1 unless -d $NCustom::Config{'tmp_dir'}
280 0 1 unless ok &NCustom::crud_gaurantee("$output/dir1/file1", 'read', \$msg)
282 0 1 unless ok &NCustom::crud_gaurantee("$output/dir1/file1", 'update', \$msg)
284 0 1 unless ok !&NCustom::crud_gaurantee("$output/dir1/file9", 'update', \$msg)
289 0 1 unless ok &NCustom::crud_gaurantee("$output/dir1/file1", 'delete', \$msg)
291 0 1 unless ok &NCustom::crud_gaurantee("$output/dir1/file9", 'create', \$msg)
293 0 1 unless ok &NCustom::crud_gaurantee("$output/dir1/subdir1/file9", 'create', \$msg)
296 0 1 unless ok &NCustom::crud_gaurantee("$output/dir1/file1", 'r', \$msg)
298 0 1 unless ok !&NCustom::crud_gaurantee("$output/dir1/file9", 'r', \$msg)
300 0 1 unless ok &NCustom::crud_gaurantee("$output/dir1/file1", 'ru', \$msg)
319 109 33 if ($check =~ /create/i or $check =~ /^[crud]+$/i and $check =~ /c/i)
320 52 57 unless (-e dirname($file))
322 0 52 unless ($rc)
324 0 109 unless (-w dirname($file))
327 0 109 if (-e $file and not -f $file)
330 0 109 if (-f $file and not -w $file)
336 30 112 if ($check =~ /read/i or $check =~ /^[crud]+$/i and $check =~ /r/i)
337 1 29 unless (-e $file)
340 0 29 unless (-f $file)
343 0 29 unless (-r $file)
349 3 138 if ($check =~ /update/i or $check =~ /^[crud]+$/i and $check =~ /u/i)
350 1 2 unless (-e $file)
353 0 2 unless (-f $file)
356 0 2 unless (-r $file)
359 0 2 unless (-w $file)
365 21 119 if ($check =~ /delete/i or $check =~ /^[crud]+$/i and $check =~ /d/i)
367 0 21 unless (-e $file)
370 0 21 unless (-f $file)
373 0 21 unless (-w dirname($file))
389 0 1 unless ok -f "$output/dir2/file1"
391 0 1 unless can_ok 'NCustom', 'save_files'
412 0 1 unless ok -f "$output/.ncustom/save/all/$output/dir2/file1"
418 0 1 unless ok -f "$output/.ncustom/save/tx1/$output/dir2/file1"
423 0 1 unless ok -f "$output/.ncustom/save/all/$output/dir2/file2"
429 0 1 unless ok -f "$output/.ncustom/save/tx1/$output/dir2/file2"
434 0 1 unless ok -f "$output/.ncustom/save/all/$output/dir3/file1"
436 0 1 unless ok -f "$output/.ncustom/save/tx1/$output/dir3/file1"
438 0 1 unless ok -f "$output/.ncustom/save/all/$output/dir3/file2"
440 0 1 unless ok -f "$output/.ncustom/save/tx1/$output/dir3/file2"
447 0 1 unless ok -f "$output/.ncustom/save/tx2/$output/dir4/file1"
452 0 1 unless ok !(-f "$output/.ncustom/save/tx1/$output/dir4/file1")
460 0 1 unless is $#matches, 1
469 0 1 unless is $#matches, 1
488 0 13 unless save_file($file)
507 0 35 unless save_file2($f, $global_dest)
508 0 35 unless save_file2($f, $local_dest)
509 11 24 unless (-e $f)
512 7 4 unless -d "$NCustom::Config{'save_dir'}/$NCustom::Transaction"
518 0 11 unless ($rc)
524 0 11 unless ($rc)
541 22 48 unless (-e $file)
546 0 48 if (-e $dest and compare($dest, $file) == 0)
552 4 44 if (-e $dest and compare($dest, $file) != 0)
559 0 48 unless ($rc)
562 0 48 unless ($rc)
575 0 66 if $line =~ /^#/
595 0 1 unless can_ok 'NCustom', 'initialise'
610 0 1 unless is $#matches, 3
612 0 1 unless ok -d "$output/.ncustom/save/all"
620 0 1 unless rmtree($NCustom::Config{'save_dir'})
621 0 1 unless mkpath("$NCustom::Config{'save_dir'}/all")
622 0 1 unless mkpath("$NCustom::Config{'save_dir'}/all.new")
623 0 1 unless mkpath("$NCustom::Config{'save_dir'}/$NCustom::Transaction")
624 0 1 unless mkpath("$NCustom::Config{'save_dir'}/$NCustom::Transaction.new")
625 0 1 unless rmtree($NCustom::Config{'tmp_dir'})
626 0 1 unless mkpath($NCustom::Config{'tmp_dir'})
642 0 1 unless ok -f "$output/dir5/file1"
644 0 1 unless ok !(-f "$output/.ncustom/save/tx1/$output/dir5/file1")
651 0 1 unless is compare("$output/dir5/file1", "$input/dir5file1.v2"), 0
653 0 1 unless is compare("$output/.ncustom/save/tx1/$output/dir5/file1", "$input/dir5file1"), 0
658 0 1 unless ok -f "$output/dir5/subdir1/file1"
673 0 20 unless ($rc)
676 0 20 unless ($rc)
679 0 20 unless ($rc)
682 0 20 unless ($rc)
685 0 20 unless ($rc)
698 0 1 unless can_ok 'NCustom', 'overwrite_file'
731 0 1 unless is compare("$output/dir6/file1", "$input/dir6file1.v2"), 0
739 0 1 unless is compare("$output/dir6/file2", "$input/dir6file2.v2"), 0
745 0 1 unless is compare("$output/dir6/subdir1/file1", "$input/dir6file1.v2"), 0
765 0 15 if ($files eq '')
768 0 15 unless ($change =~ /^(overwrite|append|prepend|edit)$/)
773 5 10 unless $strip eq ''
780 0 17 unless ($rc)
798 0 17 unless ($rc)
800 6 11 if ($change =~ /overwrite/)
805 3 14 if ($change =~ /append/)
806 1 2 if (-e $file)
808 0 1 unless ($rc)
815 3 14 if ($change =~ /prepend/)
819 1 2 if -f $file
821 5 12 if ($change =~ /edit/)
823 0 5 unless ($rc)
832 0 17 if ($@)
864 0 1 unless can_ok 'NCustom', 'append_file'
886 0 1 unless is compare("$output/dir7/file1", "$input/dir7file1.v2"), 0
894 0 1 unless is compare("$output/dir7/file2", "$input/dir7file2.v2"), 0
900 0 1 unless is compare("$output/dir7/subdir1/file1", "$input/dir7file1.v2"), 0
928 0 1 unless can_ok 'NCustom', 'prepend_file'
951 0 1 unless is compare("$output/dir8/file1", "$input/dir8file1.v2"), 0
959 0 1 unless is compare("$output/dir8/file2", "$input/dir8file2.v2"), 0
965 0 1 unless is compare("$output/dir8/subdir1/file1", "$input/dir8file1.v2"), 0
993 0 1 unless can_ok 'NCustom', 'edit_file'
1032 0 1 unless is compare("$output/dir9/file1", "$input/dir9file1.v2"), 0
1038 0 1 unless is compare("$output/dir9/file2", "$input/dir9file2.v2"), 0
1043 0 1 unless is compare("$output/dir9/file3", "$input/dir9file3.v2"), 0
1045 0 1 unless is compare("$output/dir10/file1", "$input/dir10file1.v2"), 0
1047 0 1 unless is compare("$output/dir10/file2", "$input/dir10file2.v2"), 0
1073 0 1 unless can_ok 'NCustom', 'undo_files'
1113 0 1 unless ok -f "$output/dir11/file1" && -f "$output/dir11/file2"
1115 0 1 unless ok -f "$output/dir11/file3"
1117 0 1 unless ok -f "$output/dir11/file4" && -f "$output/dir11/file5"
1119 0 1 unless ok -f "$output/dir11/file6" && -f "$output/dir11/file7"
1121 0 1 unless ok !(-f "$output/dir11/file8")
1124 0 1 unless ok -f "$output/dir11/file8"
1133 0 1 unless ok -f "$output/dir12/file1" && -f "$output/dir12/file2" && -f "$output/dir12/file3"
1138 0 1 unless ok !(-f "$output/dir12/file1")
1140 0 1 unless ok -f "$output/dir12/file2" && -f "$output/dir12/file3"
1143 0 1 unless ok !(-f "$output/dir12/file1" || -f "$output/dir12/file2" || -f "$output/dir12/file3")
1161 7 2 unless (-e $dir)
1167 0 9 unless (-e $d)
1174 0 9 unless ($d =~ m[$NCustom::Config{'save_dir'}/([^/]*)])
1180 9 0 unless find(\&undo_file, "$d")
1187 3 6 if (-e $d_new)
1188 3 0 unless find(\&delete_file, $d_new)
1200 0 80 if ($file =~ /\.AT_\d+:\d+:\d+$/)
1203 57 23 unless (-f $file)
1214 15 4 unless (-f $archive_filename)
1231 0 1 unless ok !&NCustom::check_pkg($junk)
1240 0 1 unless is $$req{'result'}, 'MISSING'
1243 0 1 unless is $$req{'result'}, 'MISSING'
1246 0 1 unless is $$req{'result'}, 'MISSING'
1249 0 1 unless is $$req{'result'}, 'OK'
1256 1 0 unless is $$req{'result'}, 'OK'
1259 1 0 unless is $$req{'result'}, 'OK'
1262 1 0 unless is $$req{'result'}, 'BELOW'
1266 1 0 unless is $$req{'result'}, 'ABOVE'
1269 1 0 unless is $$req{'result'}, 'OK'
1272 1 0 unless is $$req{'result'}, 'OK'
1276 1 0 unless is $$req{'result'}, 'ABOVE'
1279 1 0 unless is $$req{'result'}, 'OK'
1282 1 0 unless is $$req{'result'}, 'BELOW'
1286 1 0 unless is $$req{'result'}, 'UNWELCOME'
1289 1 0 unless is $$req{'result'}, 'UNWELCOME'
1292 1 0 unless is $$req{'result'}, 'UNWELCOME'
1307 1 20 unless (defined $$req{'match'})
1311 0 20 unless ($$req{'match'} =~ /(MINIMUM)|(MAXIMUM)|(EXACTLY)|(NOTWANT)/)
1318 0 20 if ($rc == 0 and $$req{'match'} =~ /NOTWANT/)
1322 6 14 if ($rc != 0 and $$req{'match'} =~ /NOTWANT/)
1326 14 0 if ($rc != 0 and not $$req{'match'} =~ /NOTWANT/)
1335 0 0 if ($$req{'match'} =~ /EXACTLY/ and vcmp($ver, 'eq', $reqver))
1339 0 0 if ($$req{'match'} =~ /MINIMUM|EXACTLY/ and vcmp($ver, 'lt', $reqver))
1343 0 0 if ($$req{'match'} =~ /MAXIMUM|EXACTLY/ and vcmp($ver, 'gt', $reqver))
1360 0 1 unless can_ok 'NCustom', 'required_packages'
1402 0 1 unless like $o, qr/As EXACTLY version .* fetch FILE from URL and execute it.\n/
1404 1 0 unless like $o, qr/Dont be stupid/
1406 1 0 unless like $o, qr/Hello9/
1429 2 3 if $line =~ /^#/
1437 0 3 unless ($rc)
1439 1 2 if ($$NCustom::req{'result'} ne 'OK')
1444 0 1 if ($@)
1453 1 0 unless ($$NCustom::req{'result'} eq 'OK' and $rc)
1465 1 0 unless defined $ENV{'TEST_APT'} or defined $ENV{'TEST_ALL'}
1471 0 0 unless like $version, qr/package perl-NCustomDummy is not installed/
1475 0 0 unless can_ok 'NCustom', 'apt_fix'
1481 0 0 unless ok !$rc
1484 0 0 unless like $version, qr/1.23/
1490 0 0 unless is $rc, 1
1493 0 0 unless like $version, qr/package perl-NCustomDummy is not installed/
1505 0 0 if ($$NCustom::req{'result'} =~ /UNWELCOME/) { }
1519 0 1 unless ok !&NCustom::vcmp(1, 'gt', 2)
1521 0 1 unless ok !&NCustom::vcmp(1, 'eq', 2)
1523 0 1 unless ok !&NCustom::vcmp(3, 'gt', 3)
1525 0 1 unless ok !&NCustom::vcmp(3, 'lt', 3)
1527 0 1 unless ok !&NCustom::vcmp(3, 'ne', 3)
1531 0 1 unless ok &NCustom::vcmp(1, 'lt', 2)
1533 0 1 unless ok &NCustom::vcmp(1, 'ne', 2)
1535 0 1 unless ok &NCustom::vcmp(3, 'eq', 3)
1537 0 1 unless ok &NCustom::vcmp('1.2.3', 'lt', 2)
1539 0 1 unless ok &NCustom::vcmp('1.2.3', 'gt', '1.1.99')
1541 0 1 unless ok &NCustom::vcmp('1.2.3', 'eq', '1.2.3')
1543 0 1 unless ok &NCustom::vcmp(1, 'ne', 0)
1545 0 1 unless ok &NCustom::vcmp('1.2.3', 'lt', 2)
1547 0 1 unless ok &NCustom::vcmp('1.2.3', 'gt', '1.1.99')
1549 0 1 unless ok &NCustom::vcmp('1.2.3', 'eq', '1.2.3')
1551 0 1 unless ok &NCustom::vcmp(1, 'ne', 0)
1553 0 1 unless ok &NCustom::vcmp('1.2.3', 'lt', '1.03')
1568 0 30 unless ($cmp =~ /(lt)|(gt)|(eq)|(ne)/)
1572 0 30 unless ($vstring1 =~ /^(\d+\.)*\d*$/)
1576 0 30 unless ($vstring2 =~ /^(\d+\.)*\d*$/)
1596 11 19 if ($cmp eq 'eq')
1597 3 8 if (not defined $v1 || defined $v2) { }
0 8 elsif (not defined $v1 && defined $v2) { }
1 7 elsif ($v1 != $v2) { }
0 7 elsif ($v1 != $v2) { }
1608 5 14 if ($cmp eq 'ne')
1609 1 4 if (not defined $v1 || defined $v2) { }
0 4 elsif (not defined $v1 && defined $v2) { }
3 1 elsif ($v1 != $v2) { }
0 1 elsif ($v1 eq '' and $v2 eq '') { }
1621 7 7 if ($cmp eq 'lt')
1622 1 6 if (not defined $v1 || defined $v2) { }
0 6 elsif (not defined $v1 and defined $v2) { }
0 6 elsif (defined $v1 and not defined $v2) { }
4 2 elsif ($v1 < $v2) { }
0 2 elsif ($v1 > $v2) { }
0 2 elsif ($v1 eq '' and $v2 eq '') { }
1638 7 0 if ($cmp eq 'gt')
1639 1 6 if (not defined $v1 || defined $v2) { }
0 6 elsif (not defined $v1 and defined $v2) { }
0 6 elsif (defined $v1 and not defined $v2) { }
2 4 elsif ($v1 > $v2) { }
1 3 elsif ($v1 < $v2) { }
0 3 elsif ($v1 eq '' and $v2 eq '') { }
1666 0 1 unless can_ok 'NCustom', 'blat_myconfig'
1681 0 1 unless is compare("$output/.ncustom/NCustom/MyConfig.pm", "$input/Global.pm"), 0
1702 1 1 unless (-e $myconfig_file_dir)
1704 0 1 unless ($rc)
1709 0 2 unless (-d $myconfig_file_dir)
1716 2 2 if (-e "$i/NCustom/Config.pm")
1721 0 2 if ($global_config_file =~ /^dummy$/)
1728 0 2 unless ($rc)
1731 0 2 unless ($rc)
1734 2 124 if /^__END__/
1750 0 1 unless can_ok 'NCustom', 'config_edit'
1774 0 1 unless ok grep(/src_fqdn.*install.baneharbinger.com/, @lines) > 0
1776 0 1 unless ok grep(/test_url1.*install.baneharbinger.com/, @lines) > 0
1784 0 1 unless ok grep(/test_data1.*wow/, @lines) > 0
1786 0 1 unless ok grep(/test_data2.*whoopee doo/, @lines) > 0
1804 1 1 unless (-e $myconfig_file_dir)
1806 0 1 unless ($rc)
1808 0 2 unless (-d $myconfig_file_dir)
1813 1 1 unless (-e $myconfig_file)
1815 0 1 unless ($rc)
1827 0 2 unless ($rc)
1830 0 2 unless ($rc)
1836 2 63 if $line =~ /^\s*1;/
1838 2 35 if ($line =~ /^\s*\$Config{.$name.}/)
1845 61 2 unless $line_replaced
1859 0 2 unless ($rc)
1872 0 1 unless can_ok 'NCustom', 'ncustom'
1900 0 1 unless ok grep(/NCustom test1.ncus/, @lines) > 0
1902 0 1 unless ok grep(/NCustom test2.ncus/, @lines) > 0
1920 0 2 if $line =~ /^#/
1921 1 1 if (ncustom_try_dir($line, ''))
1922 1 1 if ($executed)
1923 0 1 if (ncustom_try_url($line, ''))
1924 0 1 if ($executed)
1928 1 0 if (-d $dir) { }
1929 1 0 if (ncustom_try_dir($line, $dir))
1930 1 0 if ($executed)
1932 0 0 if (ncustom_try_url($line, $src))
1933 0 0 if ($executed)
1936 1 0 if ($executed)
1953 2 1 if (-f $file and -x $file)
1954 0 2 if (basename($file) eq $file)
1959 0 2 unless $rc == 0
1979 0 2 if -f $_
1984 0 0 unless $rc == 0