Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

oadam
Copy link

@oadam oadam commented Nov 24, 2023

No description provided.

@phpstan-bot
Copy link
Collaborator

You've opened the pull request against the latest branch 1.11.x. If your code is relevant on 1.10.x and you want it to be released sooner, please rebase your pull request and change its target to 1.10.x.

@oadam oadam force-pushed the 1.11.x branch 3 times, most recently from bae0cbc to c5b4df4 Compare November 24, 2023 17:09
@oadam oadam changed the base branch from 1.11.x to 1.10.x November 24, 2023 17:09
@ondrejmirtes
Copy link
Member

Please link some proof this is part of the JUnit standard.

@oadam
Copy link
Author

oadam commented Nov 24, 2023

I amended the commit to try and justify the inclusion. Seems like there is no agreed upon junit standard 😢 !

no xsd here :
https://github.com/sebastianbergmann/phpunit/blob/main/src/Logging/JUnit/JunitXmlLogger.php#L298

discussion of the absence of proper junit xsd here :
sebastianbergmann/phpunit#2964

Doing the same as phpunit should be safe ?

@oadam
Copy link
Author

oadam commented Nov 24, 2023

Some of the attributes I have added are added here in PHPUnit : https://github.com/sebastianbergmann/phpunit/blob/main/src/Logging/JUnit/JunitXmlLogger.php#L428

@oadam oadam force-pushed the 1.11.x branch 3 times, most recently from ee5b53a to ddf6fd1 Compare November 24, 2023 17:57
Remove xsd all together, as is the case in phpunit :

no xsd here :
https://github.com/sebastianbergmann/phpunit/blob/main/src/Logging/JUnit/JunitXmlLogger.php#L298

discussion of the absence of proper junit xsd here :
sebastianbergmann/phpunit#2964
@@ -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">',
Copy link
Member

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

@@ -1,118 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe you can find a newer version of this schema that includes file and line?

$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));
Copy link
Member

Choose a reason for hiding this comment

The 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 RelativePathHelper. Check the other formatters.

@oadam
Copy link
Author

oadam commented Nov 27, 2023

@ondrejmirtes I'm removing any mention of a XSD because there is no official schema.

PHPUnit does not have it in its output as well : https://github.com/sebastianbergmann/phpunit/blob/main/tests/end-to-end/logging/log-junit-to-file.phpt#L26

If I add the RelativePathHelper, would you be open to merge this even with the XSD removal ?

My objective is to add file and linenumber so that, in my private repo, I can better annotate failed pull requests with https://github.com/marketplace/actions/junit-report-action (it annotates PR with annotations on offending lines)

@oadam
Copy link
Author

oadam commented Nov 27, 2023

I just realized that you have a github output format ! You can disregard this PR is removing the XSD seems too much

@ondrejmirtes
Copy link
Member

Yeah, PHPStan provides nice experience out of the box :) Thanks anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants