-
Notifications
You must be signed in to change notification settings - Fork 479
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
add filename and line number to phpunit output #2775
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ public function formatErrors( | |
|
||
$result = '<?xml version="1.0" encoding="UTF-8"?>'; | ||
$result .= sprintf( | ||
'<testsuite failures="%d" name="phpstan" tests="%d" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/junit-team/junit5/r5.5.1/platform-tests/src/test/resources/jenkins-junit.xsd">', | ||
'<testsuite failures="%d" name="phpstan" tests="%d">', | ||
$totalFailuresCount, | ||
$totalTestsCount, | ||
); | ||
|
@@ -38,6 +38,8 @@ public function formatErrors( | |
sprintf('%s:%s', $fileName, (string) $fileSpecificError->getLine()), | ||
'ERROR', | ||
$this->escape($fileSpecificError->getMessage()), | ||
$fileName, | ||
$fileSpecificError->getLine(), | ||
); | ||
} | ||
|
||
|
@@ -65,9 +67,16 @@ public function formatErrors( | |
* | ||
* | ||
*/ | ||
private function createTestCase(string $reference, string $type, ?string $message = null): string | ||
private function createTestCase(string $reference, string $type, ?string $message = null, ?string $fileName = null, ?int $lineNumber = null): string | ||
{ | ||
$result = sprintf('<testcase name="%s">', $this->escape($reference)); | ||
$result = sprintf('<testcase name="%s"', $this->escape($reference)); | ||
if ($fileName !== null) { | ||
$result .= sprintf(' file="%s"', $this->escape($fileName)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about absolute vs. relative path to the file? Typically you don't want to print the whole absolute path, but trim the beginning. But I'm not sure what PHPUnit does and what tools that read the output expect. Anyway, this is usually done with the help of |
||
} | ||
if ($lineNumber !== null) { | ||
$result .= sprintf(' line="%s"', (string) $lineNumber); | ||
} | ||
$result .= '>'; | ||
|
||
if ($message !== null) { | ||
$result .= sprintf('<failure type="%s" message="%s" />', $this->escape($type), $this->escape($message)); | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you remove this? Maybe it's important