On Sun, Oct 21, 2018, 12:09 Richard Hainsworth <rnhainswo...@gmail.com> wrote:
> I am trying to find a way to send a message via STDERR to a user, and to > exit, but to eliminate the backtrace printing. > > so .. either I use your suggestion of 'exit note $message' which I find > elegant, but so far difficult to test. > That is the way to do it. (I tried timo's suggestion of &*EXIT = -> | { die 'exited' } > And that is the way to test it. but then I cant work out how to get the message. I've been looking at > Zoffix's Test::Output, but not Incomplete sentence there. I guess it doesn't work for you? Tell us how you tried to use it, what you were expecting, and what happened instead. I guess I should look into porting Test::Trap to Perl6 ... in Perl5, I'd just write the test like so: trap { some_code() }; $trap->stderr_like(qr/some pattern/, 'stderr from some_code matches some pattern'); $trap->did_exit('some_code exited'); # or if you care about the exact exit code: $trap->exit_is(1, 'exit code 1 from some_code'); ... or thereabouts. I'm stuck on my phone and no perl at the moment ... Eirik