mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2741 from simonwelsh/hhvm-test
Changes to error message detection to handle the differences in HHVM
This commit is contained in:
commit
3d2875a111
@ -13,7 +13,7 @@ class ErrorControlChainTest_Chain extends ErrorControlChain {
|
|||||||
return parent::translateMemstring($memstring);
|
return parent::translateMemstring($memstring);
|
||||||
}
|
}
|
||||||
|
|
||||||
function executeInSubprocess() {
|
function executeInSubprocess($includeStderr = false) {
|
||||||
// Get the path to the ErrorControlChain class
|
// Get the path to the ErrorControlChain class
|
||||||
$classpath = SS_ClassLoader::instance()->getItemPath('ErrorControlChain');
|
$classpath = SS_ClassLoader::instance()->getItemPath('ErrorControlChain');
|
||||||
$suppression = $this->suppression ? 'true' : 'false';
|
$suppression = $this->suppression ? 'true' : 'false';
|
||||||
@ -47,7 +47,11 @@ require_once '$classpath';
|
|||||||
// Now stick it in a temporary file & run it
|
// Now stick it in a temporary file & run it
|
||||||
$codepath = TEMP_FOLDER.'/ErrorControlChainTest_'.sha1($src).'.php';
|
$codepath = TEMP_FOLDER.'/ErrorControlChainTest_'.sha1($src).'.php';
|
||||||
|
|
||||||
|
if($includeStderr) {
|
||||||
|
$null = '&1';
|
||||||
|
} else {
|
||||||
$null = is_writeable('/dev/null') ? '/dev/null' : 'NUL';
|
$null = is_writeable('/dev/null') ? '/dev/null' : 'NUL';
|
||||||
|
}
|
||||||
|
|
||||||
file_put_contents($codepath, $src);
|
file_put_contents($codepath, $src);
|
||||||
exec("php $codepath 2>$null", $stdout, $errcode);
|
exec("php $codepath 2>$null", $stdout, $errcode);
|
||||||
@ -185,9 +189,10 @@ class ErrorControlChainTest extends SapphireTest {
|
|||||||
->then(function($chain){
|
->then(function($chain){
|
||||||
Foo::bar(); // Non-existant class causes fatal error
|
Foo::bar(); // Non-existant class causes fatal error
|
||||||
})
|
})
|
||||||
->executeInSubprocess();
|
->executeInSubprocess(true);
|
||||||
|
|
||||||
$this->assertContains("Fatal error: Class 'Foo' not found", $out);
|
$this->assertContains('Fatal error', $out);
|
||||||
|
$this->assertContains('Foo', $out);
|
||||||
|
|
||||||
// Turning off suppression during execution
|
// Turning off suppression during execution
|
||||||
|
|
||||||
@ -198,9 +203,10 @@ class ErrorControlChainTest extends SapphireTest {
|
|||||||
$chain->setSuppression(false);
|
$chain->setSuppression(false);
|
||||||
Foo::bar(); // Non-existent class causes fatal error
|
Foo::bar(); // Non-existent class causes fatal error
|
||||||
})
|
})
|
||||||
->executeInSubprocess();
|
->executeInSubprocess(true);
|
||||||
|
|
||||||
$this->assertContains("Fatal error: Class 'Foo' not found", $out);
|
$this->assertContains('Fatal error', $out);
|
||||||
|
$this->assertContains('Foo', $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testDoesntAffectNonFatalErrors() {
|
function testDoesntAffectNonFatalErrors() {
|
||||||
|
Loading…
Reference in New Issue
Block a user