Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^2: Testing redirected croak messages

by macrobat (Beadle)
on Oct 28, 2005 at 00:02 UTC ( #503513=note: print w/replies, xml ) Need Help??


in reply to Re: Testing redirected croak messages
in thread Testing redirected croak messages

I'm not sure if I'm using Test::Exception right. Here's the gist of my original test, with the code in eval pulled out and switched to use dies_ok():

unlink 'test.errors'; redirect_error( output_file => 'test.errors' ); # sets $redirected{err +or_messages} to 1 dies_ok { lcroak "this is a sample error file" }; ok( -T 'test.errors', "lcroak opens the error file specified by redirect_error()." ); my $text = `cat test.errors`; like( $text , qr/this is a sample error file/, "lcroak writes to the error file specified by redirect_error()." ) +; unlink 'test.errors';
--and I get this:

# Failed test 'lcroak writes to the error file specified by redirect +_error().' t/lcroak....NOK 4# in t/lcroak.t at line 25. # '' # doesn't match '(?-xism:this is a sample error file)' # Looks like you failed 1 test of 4.
I did try local $@, like so, but perhaps I'm doing it wrong:

{ local $@; eval { lcroak "this is a sample error file"; }; ok($@, "lcroak terminates"); }
That still redirect STDERR to test.error, however.

Replies are listed 'Best First'.
Re^3: Testing redirected croak messages
by chromatic (Archbishop) on Oct 28, 2005 at 06:59 UTC

    It's difficult to say without seeing the code for lcroak() and redirect_error() (probably including the hash declaration).

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://503513]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (4)
As of 2022-12-06 06:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?