Skip to content

Set default Clover coverage project name #6210

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

Closed

Conversation

Staubiii
Copy link
Contributor

Some Clover XML report processing tools require the project name to be set.

e.g. https://issues.jenkins.io/browse/JENKINS-75648

Could this be backported to phpunit 8.5?

Some Clover XML report processing tools require the project name to be set.

e.g. https://issues.jenkins.io/browse/JENKINS-75648
@sebastianbergmann sebastianbergmann added the feature/code-coverage Issues related to code coverage (but not php-code-coverage) label May 19, 2025
@sebastianbergmann
Copy link
Owner

sebastianbergmann commented May 19, 2025

Thank you for your contribution.

I am open to the change you propose. However, if I look at https://bitbucket.org/atlassian/clover/raw/master/etc/schema/clover.xsd and understand ...

<xs:element name="project">
    <xs:annotation>
        <xs:documentation>
            Project metrics relating to non-test source.
            @name - project name (optional)
            @timestamp - seconds since UTC
        </xs:documentation>
    </xs:annotation>
    <xs:complexType>
        <xs:sequence>
            <xs:element name="metrics" type="projectMetrics"/>
            <xs:element maxOccurs="unbounded" ref="package"/>
        </xs:sequence>
        <xs:attribute name="name"/>
        <xs:attribute name="timestamp" use="required" type="xs:integer"/>
    </xs:complexType>
</xs:element>

... correctly then the name attribute is optional whereas the timestamp attribute is not. It is interesting that your parser seems to choke on the optional attribute that is missing but not on the non-optional attribute that is missing.

@sebastianbergmann
Copy link
Owner

I totally missed in my first comment that the Clover XML writer in fact does generate the timestamp attribute, my bad.

@sebastianbergmann
Copy link
Owner

I am open to accepting the change you propose. I am reluctant to change PHPUnit 8.5, PHPUnit 9.6, and PHPUnit 10.5 as these versions have reached the end of their bugfix support. The proposed change should go into 11.5, 12.1, and main.

It would help me if somebody could look into whether https://bitbucket.org/atlassian/clover/raw/master/etc/schema/clover.xsd is, in fact, the official/canonical schema for Clover XML and, if it is, look into whether there are any other changes PHPUnit (or phpunit/php-code-coverage, rather) needs to implement to comply with the schema.

@sebastianbergmann
Copy link
Owner

I cherry-picked this into 11.5 and merged it to 12.1 and main from there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/code-coverage Issues related to code coverage (but not php-code-coverage)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants