-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
156 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--TEST-- | ||
GH-1340: Process isolation blocks infinitely upon fatal error | ||
--FILE-- | ||
<?php | ||
|
||
$_SERVER['argv'][1] = '--no-configuration'; | ||
$_SERVER['argv'][3] = 'Issue1340Test'; | ||
$_SERVER['argv'][4] = dirname(__FILE__).'/1340/Issue1340Test.php'; | ||
|
||
require __DIR__ . '/../../bootstrap.php'; | ||
PHPUnit_TextUI_Command::main(); | ||
?> | ||
--EXPECTF-- | ||
PHPUnit %s by Sebastian Bergmann. | ||
%A | ||
.E.EE | ||
|
||
Time: %s, Memory: %sMb | ||
|
||
There were 3 errors: | ||
|
||
1) Issue1340Test::testLargeStderrOutputDoesNotBlockInIsolation | ||
PHPUnit_Framework_Exception: testLargeStderrOutputDoesNotBlockInIsolation: stderr:%d | ||
%A | ||
2) Issue1340Test::testPhpNoticeWithStderrOutputIsAnError | ||
PHPUnit_Framework_Exception: shutdown: stderr:%d | ||
%A | ||
3) Issue1340Test::testFatalErrorDoesNotPass | ||
PHPUnit_Framework_Exception: Fatal error: Call to undefined function undefined_function() in %s on line %d | ||
%A | ||
shutdown: stderr:%d | ||
%A | ||
FAILURES! | ||
Tests: 5, Assertions: 3, Errors: 3. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
/** | ||
* @see https://bugs.php.net/bug.php?id=51800 | ||
*/ | ||
class Issue1340Test extends PHPUnit_Framework_TestCase | ||
{ | ||
private static function get4KB() | ||
{ | ||
return str_repeat('1', 4096 + 1); | ||
} | ||
|
||
/** | ||
* Also fails despite no isolation, because a phpt test is executed in | ||
* subprocess on its own. | ||
*/ | ||
public function testLargeStderrOutputDoesNotBlock() | ||
{ | ||
// STDERR of a phpt test is not caught/validated at this point, so this | ||
// error output does not cause this test to fail. | ||
// @see https://github.com/sebastianbergmann/phpunit/issues/1169 | ||
error_log("\n" . __FUNCTION__ . ": stderr:" . self::get4KB() . "\n"); | ||
$this->assertTrue(true); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
*/ | ||
public function testLargeStderrOutputDoesNotBlockInIsolation() | ||
{ | ||
error_log("\n" . __FUNCTION__ . ": stderr:" . self::get4KB() . "\n"); | ||
$this->assertTrue(true); | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @expectedException \PHPUnit_Framework_Error_Notice | ||
* @expectedExceptionMessage Undefined variable: foo | ||
*/ | ||
public function testPhpNoticeIsCaught() | ||
{ | ||
$bar = $foo['foo']; | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
* @expectedException \PHPUnit_Framework_Error_Notice | ||
* @expectedExceptionMessage Undefined variable: foo | ||
*/ | ||
public function testPhpNoticeWithStderrOutputIsAnError() | ||
{ | ||
register_shutdown_function(__CLASS__ . '::onShutdown'); | ||
$bar = $foo['foo']; | ||
} | ||
|
||
/** | ||
* @runInSeparateProcess | ||
*/ | ||
public function testFatalErrorDoesNotPass() | ||
{ | ||
register_shutdown_function(__CLASS__ . '::onShutdown'); | ||
$undefined = 'undefined_function'; | ||
$undefined(); | ||
} | ||
|
||
public static function onShutdown() { | ||
echo "\nshutdown: stdout:", self::get4KB(), "\n"; | ||
error_log("\nshutdown: stderr:" . self::get4KB()); | ||
} | ||
} |