Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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.

In reply to Re^2: Testing redirected croak messages by macrobat
in thread Testing redirected croak messages by macrobat

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2023-01-29 18:27 GMT
Find Nodes?
    Voting Booth?

    No recent polls found