Jul 8, 2014, 4:15 PM
Post #4 of 4
From the documentation (update: this doesn't actually explain how Test::More prevents output, I can't figure out from the source code how it does):
Re: [zoetus] 'print' Output When Running Test::More Tests
[In reply to]
Test::Builder (which powers Test::More) duplicates STDOUT and STDERR. So any changes to them, including changing their output disciplines, will not be seem [sic] by Test::More.
And for your question:
Does anyone know why Test::More is actually doing this
Test prints would be muddied / intermingled within your own prints (not just your debug ones), which in most cases would be undesirable. Also, The purpose of a test is not to check output or debug your code, your code should be assumed working. I personally write a test and a usage, the usage being a quick rough script which usually uses the module etc for its intended purpose. Or if I don't have time to write a usage, I'll debug directly with my production script.
I suggest that you do not print debug statements to STDOUT. I would make use of a logging module such as Log::Log4perl and ensure calls to $log->debug( ) are directed to an appropriate handle.
(This post was edited by Zhris on Jul 8, 2014, 5:36 PM)