complete report template with optional variables
[barcat.git] / t / examples.t
index cfe0e3f73e2c75e76618c47389933c1306015b55..c9b285e70d84a6b410b4951d24e2b248a2e4c9da 100755 (executable)
@@ -2,7 +2,6 @@
 use 5.014;
 use warnings;
 use re '/ms';
-use IPC::Run 'run';
 
 use Test::More;
 { # silence fail diagnostics because of single caller
@@ -10,9 +9,14 @@ use Test::More;
        sub Test::Builder::_ok_debug {}
 }
 
+eval q(use IPC::Run 'run');
+plan skip_all => "IPC::Run required to test commands" if $@;
+
 my %CMDARGS = (
-       ping => '-c 1',
+       ping => '-c 1 ',
        'cat \Khttpd/' => '/var/log/apache2/',
+       ' \K\*(?=\h*\|)' => 'sample/media/*.*',
+       find => 'sample/media -name \*.\* ',
 );
 
 my $filename = 'barcat';
@@ -68,8 +72,8 @@ SKIP: {
 
        # prepare shell command to execute
        while (my ($subcmd, $args) = each %CMDARGS) {
-               $subcmd .= " \\K", $args .= ' ' unless $subcmd =~ m/\\K/;
-               $cmd =~ s/\b$subcmd/$args/;
+               $subcmd .= " \\K" unless $subcmd =~ m/\\K/;
+               $cmd =~ s/$subcmd/$args/;
        }
 
        for my $param ($cmd =~ m{^[(\h]* (\w\S*)}gx) {