in reply to Getting test status with Test::More

That grep you gave should work OK.

A possible alternative is to use an END block, and check $? in it to see if you're about to return a successful 0 (and if so clean up). That also has the advantage of catching if you somehow exit early, though it's likely that an early exit is the result of an error anyway, so it wouldn't matter.

(n.b. I haven't tested that the END usage will actually DTRT, but it sounds like it work work)

  • Comment on Re: Getting test status with Test::More

Replies are listed 'Best First'.
Re^2: Getting test status with Test::More
by Anonymous Monk on Aug 12, 2009 at 17:11 UTC
    Thanks for the suggestion. Tried it out and unfortunately it didn't work. I suspect its in the order that the END blocks are called, as $? didn't appear to have been set yet.
      $? should be set, this come from http://perldoc.perl.org/perlmod.html:

      "Inside an END code block, $? contains the value that the program is going to pass to exit(). You can modify $? to change the exit value of the program. Beware of changing $? by accident (e.g. by running something via system)."