Skip to content

Support --exclude-source-from-xml-coverage fast path for PHPUnit 12.5+#2604

Merged
theofidry merged 3 commits intoinfection:masterfrom
staabm:sup
Dec 5, 2025
Merged

Support --exclude-source-from-xml-coverage fast path for PHPUnit 12.5+#2604
theofidry merged 3 commits intoinfection:masterfrom
staabm:sup

Conversation

@staabm
Copy link
Contributor

@staabm staabm commented Nov 28, 2025

requires


when PHPUnit needs to generate the <source> element in coverage-xml reports it spents a considerable amount of time generating the this information. infection does not make use of it though.

therefore we utilize --exclude-source-from-xml-coverage which will be available as of PHPUnit 12.5+ to prevent this unnecessary work and speedup the process. on phpstan-src we can see a ~15% speedup of the coverage-xml generation process (which takes up to 1 minute in CI)

}

#[Group('integration')]
public function test_it_provides_initial_test_run_command_line_when_coverage_report_is_requested_and_pcov_is_in_use(): void
Copy link
Contributor Author

@staabm staabm Nov 28, 2025

Choose a reason for hiding this comment

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

initially I tried to use a data-provider on this test, but because of the exzessiv use of mocks we nearly need to change every line. therefore a data-provider would need a lot of parameters and this would turn this test into a unreadable mess.

therefore I decided to add a separate test to not overcomplicate things.

theofidry pushed a commit that referenced this pull request Nov 28, 2025
…ethod (#2607)

Preparation for #2604 where we will create the adapter differently based on the version used.
@staabm staabm marked this pull request as ready for review November 28, 2025 10:17
@staabm
Copy link
Contributor Author

staabm commented Nov 28, 2025

I think we should wait until PHPUnit 12.5.0 is released before merging. Feedback is welcome before that though :)

looking at CI I cannot see whether we have test running for newer PHPUnit versions like 12.x .. all jobs I had a look at are running 11.x ..? I just found tests/e2e/PHPUnit12 which seems to be good enough

Copy link
Member

@theofidry theofidry left a comment

Choose a reason for hiding this comment

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

Looks good!

@theofidry
Copy link
Member

Let's wait for PHPUnit 12.5.0 then!

Co-authored-by: Théo FIDRY <5175937+theofidry@users.noreply.github.com>
@staabm
Copy link
Contributor Author

staabm commented Dec 5, 2025

since 12.5.0 was released today, this should be good to go

@theofidry theofidry merged commit f0cafe0 into infection:master Dec 5, 2025
70 of 72 checks passed
@theofidry
Copy link
Member

Thank you @staabm!

I'm kinda curious how drastic the size is gonna be, looking forward to check it out in the Infection benchmark-source.

@staabm staabm deleted the sup branch December 5, 2025 18:07
@staabm
Copy link
Contributor Author

staabm commented Dec 6, 2025

another data-point: while coverage-xml report generation was already super fast (~100ms) when running on the ParaTest codebase, adding --exclude-source-from-xml-coverage makes it ~50% faster

see paratestphp/paratest#1056

@theofidry
Copy link
Member

Before:

make generate_coverage  61.94s user 5.23s system 91% cpu 1:13.48 total
du -sh dist/coverage/*
 12M	dist/coverage/junit.xml
 56M	dist/coverage/xml

After:

make generate_coverage  53.21s user 4.10s system 95% cpu 1:00.02 total
du -sh dist/coverage/*
 12M	dist/coverage/junit.xml
 28M	dist/coverage/xml

So it was 14% faster and 50% lighter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants