-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test swallows output buffer when run in a separate process #1149
Comments
I know that both output buffering and running tests in separate processes were sources of annoying issues for phpunit, and both are not regular use cases, so consider this a low priority issue or something. |
I use process isolation a lot. It is important for testing stuff like a class loader. |
@donquixote You can actually open php://stdout directly and write to it. The stuff printed will cause an error in deserialization of the test results and will be output as an Exception. I guess this indicates that what's missing is transmission of the output from the test in the serialized data. |
I can confirm that the output is not re-printed to STDOUT.
The process isolation script template ob_start();
$test->run($result);
$output = ob_get_clean();
print serialize(
array(
'testResult' => $test->getResult(),
'numAssertions' => $test->getNumAssertions(),
'result' => $result,
'output' => $output
)
); If I get you right, then you'd like the subprocess output to get forwarded to STDOUT of the parent/main process?
if (!empty($stderr)) {
$result->addError(
$test,
new PHPUnit_Framework_Exception(trim($stderr)), $time
); It seemingly forwards STDOUT, too: if ($childResult !== false) {
if (!empty($childResult['output'])) {
print $childResult['output'];
} The if (strpos($stdout, "#!/usr/bin/env php\n") === 0) {
$stdout = substr($stdout, 19);
}
$childResult = unserialize(str_replace("#!/usr/bin/env php\n", '', $stdout)); So theoretically, output of the child process should be forwarded to the parent process already. Perhaps there's a bug in this code though. Can you debug? Alternatively, the execution of tests running in isolation may be wrapped into another output buffer somewhere else. |
This should be fixed in the next stable release. Thanks! |
@whatthejeff Awesome! Question: Is a technical analysis like mine above helpful? Or useless noise? I'm just starting to dive deep, so I don't consider myself to be in a position to fix issues like this directly (just yet), but thought it might be helpful to share insights gathered while debugging other stuff ;) Just curious whether comments like the above are a waste of everyone's time :) |
@sun It's actually very helpful and very much appreciated! |
What version was this released in? To answer my own question, it was released in v4.1.5.
Which is odd, because I am running v4.7.6, and I am still experiencing this issue of PHPUnit swallowing output when run in separate processes. |
I am experiencing the same issue: PHPUnit swallowing output when run in separate processes. using version 5.6.3 |
The text was updated successfully, but these errors were encountered: