Summary
new CodecovPlugin(level: CoverageLevel::Branch) in testo.php has no effect when the reports come from CLI flags instead of the plugin's own reports argument. The configured level is dropped silently and the run collects Line coverage.
// testo.php
plugins: [new CodecovPlugin(level: CoverageLevel::Branch)]
php -dxdebug.mode=coverage vendor/bin/testo run --coverage-clover=runtime/clover.xml
Result: <metrics ... conditionals="0" coveredconditionals="0"> — no branch data. Move the same report into the plugin and branch data appears:
plugins: [new CodecovPlugin(
level: CoverageLevel::Branch,
reports: [new CloverReport('runtime/clover.xml')],
)]
Reproduced on 1.x (b109c632), PHP 8.4.23 + Xdebug 3.4.0, Testo 0.10.38.
Cause
CodecovPlugin::configure() claims the CLI-flag reports and then returns early when this instance
has nothing to write:
$reports = [...$this->reports, ...$activation->claimCliReports($input)];
if ($reports === [] && $mode !== CoverageMode::Always) {
return; // <- level, testTypes and mode are all lost here
}
$activation->contribute($this->level, $this->testTypes, $reports, $mode);
claimCliReports() hands the flag-driven reports to whichever instance configures first, and the inert shadow default from ApplicationPlugins::defaults() configures before user plugins. So the shadow claims --coverage-clover and contributes its own default CoverageLevel::Line; the user's instance is then left with an empty report list and returns before contribute() ever sees its level. The user's testTypes and collect mode are lost the same way.
The early return is meant to keep an instance with nothing to write inert. But "has no reports of its own" and "contributes no configuration" are different things — CoverageActivation already merges level/mode/testTypes across instances, and an instance with no reports is harmless there.
Suggested fix
Contribute configuration whenever the mode is not Never, and gate only report emission on the merged report list — CoverageActivation::onSessionStarting() already returns early when $this->reports === [], so an all-inert run stays inert:
$activation->contribute($this->level, $this->testTypes, $reports, $mode);
$activation->verifyDriverRequirement();
Worth double-checking that the shadow default's Line contribution can't win over a user's deeper level — contribute() already takes the deepest level, so it can't, but a self-test should pin it.
Regression test
CodecovPlugin(level: Branch) + --coverage-clover must produce a report with conditionals > 0.
Summary
new CodecovPlugin(level: CoverageLevel::Branch)intesto.phphas no effect when the reports come from CLI flags instead of the plugin's ownreportsargument. The configured level is dropped silently and the run collectsLinecoverage.Result:
<metrics ... conditionals="0" coveredconditionals="0">— no branch data. Move the same report into the plugin and branch data appears:Reproduced on
1.x(b109c632), PHP 8.4.23 + Xdebug 3.4.0, Testo 0.10.38.Cause
CodecovPlugin::configure()claims the CLI-flag reports and then returns early when this instancehas nothing to write:
claimCliReports()hands the flag-driven reports to whichever instance configures first, and the inert shadow default fromApplicationPlugins::defaults()configures before user plugins. So the shadow claims--coverage-cloverand contributes its own defaultCoverageLevel::Line; the user's instance is then left with an empty report list and returns beforecontribute()ever sees itslevel. The user'stestTypesandcollectmode are lost the same way.The early return is meant to keep an instance with nothing to write inert. But "has no reports of its own" and "contributes no configuration" are different things —
CoverageActivationalready merges level/mode/testTypes across instances, and an instance with no reports is harmless there.Suggested fix
Contribute configuration whenever the mode is not
Never, and gate only report emission on the merged report list —CoverageActivation::onSessionStarting()already returns early when$this->reports === [], so an all-inert run stays inert:Worth double-checking that the shadow default's
Linecontribution can't win over a user's deeper level —contribute()already takes the deepest level, so it can't, but a self-test should pin it.Regression test
CodecovPlugin(level: Branch)+--coverage-clovermust produce a report withconditionals > 0.