Created
April 11, 2025 20:06
-
-
Save tbrowder/5895bf396a2fcbb901cad99392494630 to your computer and use it in GitHub Desktop.
test Proc::Async::Timeout with my code
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# @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