From f63df915b63775f1593664cb6cc47ead45108bdb Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Thu, 17 Nov 2022 21:41:49 +0100 Subject: [PATCH] t/examples: skip missing command dependencies Assume requirement at line start, and not a mistake if not found locally. --- t/examples.t | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/t/examples.t b/t/examples.t index a331ce3..29f7c50 100755 --- a/t/examples.t +++ b/t/examples.t @@ -21,6 +21,7 @@ open my $input, '<', $filename local $/ = "\n\n"; while (readline $input) { +SKIP: { # find scriptlets in the appropriate section /^=head1 EXAMPLES/ ... /^=head1/ or next; /^\h/ or next; # indented code snippet @@ -68,6 +69,12 @@ while (readline $input) { $cmd =~ s/\b$subcmd/$args/; } + 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) @@ -79,7 +86,7 @@ while (readline $input) { if (open my $record, '>', "sample/out/t$numprefix-$name.txt") { print {$record} $output; } -} +}} sub runres { my ($cmd) = @_; -- 2.30.0