in reply to Capturing stderr from a test script executed by Test::Harness::Straps

Something that might work (maybe), would be to open like this:
open( FILE, "$command 2>&1 |" );
What that does (if it works) is to put both STDERR and STDOUT together into the pipe. But then you have to know how to separate the error output from the non-error output, which might be a problem... (There shouldn't be any problem with lines being broken, but the relative ordering of stderr lines vs. stdout lines is not likely to be predictable or even consistent.)

I have a suspicion that it might not work on all OS's -- it should work on any unix-like system.)

  • Comment on Re: Capturing stderr from a test script executed by Test::Harness::Straps
  • Download Code

Replies are listed 'Best First'.
Re^2: Capturing stderr from a test script executed by Test::Harness::Straps
by DrWhy (Chaplain) on Oct 18, 2005 at 04:29 UTC
    Yes, this solution occurred to me as well, and in fact the postprocessing that THS does would effectively separate the stdout (test result lines) and stderr (diag lines) as long as the test script conformed exactly to the TAP protocol, but that would entail modifying THS itself, a CPAN module not written or maintained by me, something which I am not willing to do at this point.

    I was hoping there might be some way to redfine/manipulate STDERR in my script in order to capture it, but I suspect this will not work, since the test script is running in a separate process.

    --DrWhy

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."