+
+ for my $param ($cmd =~ m{^[(\h]* (\w\S*)}gx) {
+ $param eq 'cat' or
+ runres(['which', $param])
+ or diag("dependency $param missing at $ref\n$cmd"), skip($name, 1);
+ }
+
+ # run and report unexpected results
+ my $output = runres($cmd);
+ ok(!!$output, $name)
+ or diag("command at $ref\n$cmd\n" . ($@ || 'empty output'));
+ defined $output or next;
+
+ # record output for review
+ my $numprefix = sprintf '%02d', Test::More->builder->current_test;
+ if (open my $record, '>', "sample/out/t$numprefix-$name.txt") {
+ print {$record} $output;
+ }
+}}
+
+sub runres {
+ my ($cmd) = @_;
+ ref $cmd eq 'ARRAY'
+ or $cmd = [bash => -c => "set -o pipefail\n$cmd"];
+ eval {
+ run($cmd, \undef, \my $output, \my $error);
+ die("error message:\n".($error =~ s/^/ /gr)."\n") if $error;
+ $? == 0 or die "exit status ", $? >> 8, "\n";
+ return $output;
+ };