Skip to content

Instantly share code, notes, and snippets.

@tbrowder
Created April 11, 2025 20:06
Show Gist options
  • Save tbrowder/5895bf396a2fcbb901cad99392494630 to your computer and use it in GitHub Desktop.
Save tbrowder/5895bf396a2fcbb901cad99392494630 to your computer and use it in GitHub Desktop.
test Proc::Async::Timeout with my code
# @gfldex
use Test;
use Proc::Async::Timeout;
use Mi6::Helper;
my $timeout = 10;
dies-ok {
my $s = Proc::Async.new(
run "sbin/get-response", "file=some-file"
);
$s.stdout.lines.tap: { .say if .lc.contains(any <some-file>) }
$s.stderr.tap: { Nil }
await $s.start: timeout => $timeout;
CATCH {
when X::Proc::Async::Timeout {
say "caught: ", .^name;
say "reporting: ", .Str;
}
when X::Promise::Broken ^ X::Proc::Async::Timeout {
say "something else went wrong";
}
}
# OUTPUT:
# cought: X::Proc::Async::Timeout+{X::Promise::Broken}
# reporting: ⟨sleep⟩ timed out after 2 seconds.
}, " run without 'force' option for a missing hidden file"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment