Skip to content

Commit 9416861

Browse files
committed
improve date stripping from error log
1 parent e008eb3 commit 9416861

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Framework/TestCase.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,17 +1275,15 @@ private function runTest(): mixed
12751275
if ($this->expectErrorLog) {
12761276
$this->assertNotEmpty($errorLogOutput, 'Test did not call error_log().');
12771277
} else {
1278-
// strip date from logged error, see https://github.com/php/php-src/blob/c696087e323263e941774ebbf902ac249774ec9f/main/main.c#L905
1279-
print preg_replace('/\[.+\] /', '', $errorLogOutput);
1278+
print $this->stripDateFromErrorLog($errorLogOutput);
12801279
}
12811280
}
12821281
} catch (Throwable $exception) {
12831282
if ($capture !== false) {
12841283
if (!$this->expectErrorLog) {
12851284
$errorLogOutput = stream_get_contents($capture);
12861285

1287-
// strip date from logged error, see https://github.com/php/php-src/blob/c696087e323263e941774ebbf902ac249774ec9f/main/main.c#L905
1288-
print preg_replace('/\[.+\] /', '', $errorLogOutput);
1286+
print $this->stripDateFromErrorLog($errorLogOutput);
12891287
}
12901288
}
12911289

@@ -1310,6 +1308,12 @@ private function runTest(): mixed
13101308
return $testResult;
13111309
}
13121310

1311+
private function stripDateFromErrorLog(string $log): string
1312+
{
1313+
// https://github.com/php/php-src/blob/c696087e323263e941774ebbf902ac249774ec9f/main/main.c#L905
1314+
return preg_replace('/\[\d+-\w+-\d+ \d+:\d+:\d+ [^\r\n[\]]+?\] /', '', $log);
1315+
}
1316+
13131317
/**
13141318
* @throws ExpectationFailedException
13151319
*/

0 commit comments

Comments
 (0)