+ # store curl downloads
+ s{\bcurl (\S*)(?<param>[^|]*)}{
+ my $url = $1;
+ my @params = split ' ', $+{param};
+ my $ext = (
+ $cmd =~ /\bxml/ ? 'xml' :
+ $cmd =~ / jq / ? 'json' :
+ $cmd =~ /[=.]csv\b/ ? 'csv' :
+ 'txt'
+ );
+ my ($domain, $path) = $url =~ m{//([^/]+) .*/ ([^/]*) \z}x;
+ $path =~ s/\.$ext\z//;
+ my $cache = join '.', $path =~ tr/./_/r, $domain, $ext;
+ $cache = "sample/data/$cache";
+ SKIP: {
+ -e $cache and skip($url, 1);
+ ok(defined runres(['curl', '-sS', $url, '-o', $cache, @params]), $url)
+ or diag("download at $ref: $@");
+ }
+ "cat $cache"
+ }e;
+
+ # compose an identifier from significant parts
+ do {
+ s/^\h+//; # indentation
+ s/\\\n\s*//g; # line continuations
+ s/^[(\h]+//; # subshell
+ s/^echo\ .*?\|\s*//; # preceding input
+ s/'(\S+)[^']*'/$1/g; # quoted arguments
+ s/\h*\|.*//; # subsequent pipes
+ s/^cat\ (?:\S+\/)?//; # local file
+ } for my $name = $cmd;