X-Git-Url: http://git.shiar.nl/barcat.git/blobdiff_plain/fd1358b672c565160eb163da00b404325864114d..1dd74b3f458ea405a33fd03554f5fa4587ae879b:/t/examples.t diff --git a/t/examples.t b/t/examples.t index 0b5e778..1af87e5 100755 --- a/t/examples.t +++ b/t/examples.t @@ -2,7 +2,13 @@ use 5.014; use warnings; use re '/ms'; +use IPC::Run 'run'; + use Test::More; +{ # silence fail diagnostics because of single caller + no warnings 'redefine'; + sub Test::Builder::_ok_debug {} +} my %CMDARGS = ( ping => '-c 1', @@ -42,13 +48,16 @@ while (readline $input) { $subcmd .= " \\K", $args .= ' ' unless $subcmd =~ m/\\K/; $cmd =~ s/\b$subcmd/$args/; } - $cmd =~ s/'/'\\''/g, $cmd = " bash -c 'set -o pipefail\n$cmd'"; + my @cmd = (bash => -c => "set -o pipefail\n$cmd"); # run and report unexpected results ok(eval { - qx($cmd) or return; - return $? == 0; - }, $name) or diag($cmd); + run(\@cmd, \undef, \my $output, \my $error); + die("error message:\n $error\n") if $error; + $? == 0 or die "exit status ", $? >> 8, "\n"; + length $output or die "empty output\n"; + return 1; + }, $name) or diag("Failed command\n@cmd\nfrom $filename line $.: $@"); } done_testing();