Skip to content

Commit a1228c3

Browse files
mvoriseksebastianbergmann
authored andcommitted
improve date stripping from error log
1 parent 1c2abc8 commit a1228c3

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
@@ -1325,8 +1325,7 @@ private function runTest(): mixed
13251325
$this->assertNotEmpty($errorLogOutput, 'Test did not call error_log().');
13261326
} else {
13271327
if ($errorLogOutput !== false) {
1328-
// strip date from logged error, see https://github.com/php/php-src/blob/c696087e323263e941774ebbf902ac249774ec9f/main/main.c#L905
1329-
print preg_replace('/\[.+\] /', '', $errorLogOutput);
1328+
print $this->stripDateFromErrorLog($errorLogOutput);
13301329
}
13311330
}
13321331
}
@@ -1336,8 +1335,7 @@ private function runTest(): mixed
13361335
$errorLogOutput = stream_get_contents($capture);
13371336

13381337
if ($errorLogOutput !== false) {
1339-
// strip date from logged error, see https://github.com/php/php-src/blob/c696087e323263e941774ebbf902ac249774ec9f/main/main.c#L905
1340-
print preg_replace('/\[.+\] /', '', $errorLogOutput);
1338+
print $this->stripDateFromErrorLog($errorLogOutput);
13411339
}
13421340
}
13431341
}
@@ -1364,6 +1362,12 @@ private function runTest(): mixed
13641362
return $testResult;
13651363
}
13661364

1365+
private function stripDateFromErrorLog(string $log): string
1366+
{
1367+
// https://github.com/php/php-src/blob/c696087e323263e941774ebbf902ac249774ec9f/main/main.c#L905
1368+
return preg_replace('/\[\d+-\w+-\d+ \d+:\d+:\d+ [^\r\n[\]]+?\] /', '', $log);
1369+
}
1370+
13671371
/**
13681372
* @throws ExpectationFailedException
13691373
*/

0 commit comments

Comments
 (0)