Skip to content

Commit 1a9eae6

Browse files
committed
feat(coverage): write the Clover report to an IDE-managed path
Drop the getCoverageFilePath override that hardcoded <project>/runtime/clover.xml and pass the report path to the CLI via --coverage-clover=<path> instead. The path now comes from the platform default (<system>/coverage/<project>@<config>.xml), exactly like the PhpUnit/Codeception engines, so coverage no longer needs to land in the project runtime dir. Testo's --coverage-clover flag (Symfony Console, VALUE_REQUIRED) is confirmed in the framework source.
1 parent b7232ca commit 1a9eae6

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

src/main/kotlin/com/github/xepozz/testo/coverage/TestoCoverageEngine.kt

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,16 @@ class TestoCoverageEnabledConfiguration(
1717
) : CoverageEnabledConfiguration(configuration, CoverageRunner.getInstance(PhpUnitCoverageRunner::class.java)) {
1818
override fun coverageFileNameSeparator(): String = "@"
1919

20-
// Testo writes the Clover report to a path hardcoded inside the project's `testo.php`
21-
// (see `new CloverReport(__DIR__ . '/runtime/clover.xml')`). Until Testo exposes a
22-
// `--coverage-clover=<path>` CLI flag, we mirror that convention so the IDE reads
23-
// coverage from the same place Testo writes it.
24-
override fun getCoverageFilePath(): String =
25-
configuration.project.basePath?.let { "$it/runtime/clover.xml" } ?: super.getCoverageFilePath()!!
20+
// The report path is left to the platform default (CoverageEnabledConfiguration.createCoverageFile()), an
21+
// IDE-managed path under <system>/coverage/<project>@<config>.xml — same convention as the PhpUnit/Codeception
22+
// engines. We pass that path to Testo via `--coverage-clover=<path>` (see TestoCoverageProgramRunner), so the tool
23+
// writes the Clover report exactly where the IDE reads it back, instead of a fixed runtime/ dir inside the project.
2624
}
2725

2826
/**
29-
* The Clover report lives inside the project (runtime/clover.xml), not under [com.intellij.openapi.application.PathManager.getSystemPath].
30-
* The platform's default [CoverageSuite.deleteCachedCoverageData] stays silent only for files under the system dir;
31-
* for a project file it pops a "Delete file '…' on disk?" confirmation on every rerun. The report is regenerated each
32-
* run, so we don't delete it — which also removes the prompt.
27+
* The report path is IDE-managed (under [com.intellij.openapi.application.PathManager.getSystemPath]), so the platform's
28+
* default delete-on-disk confirmation never fires. We still skip deletion: the report is regenerated each run at the
29+
* same path, so there is nothing to clean up.
3330
*/
3431
class TestoCoverageSuite(
3532
name: String,

src/main/kotlin/com/github/xepozz/testo/coverage/TestoCoverageProgramRunner.kt

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ open class TestoCoverageProgramRunner : PhpCoverageRunner() {
2121
override fun canRun(executorId: String, profile: RunProfile) =
2222
executorId == EXECUTOR_ID && profile is TestoRunConfiguration
2323

24-
override fun createCoverageArguments(targetCoverage: String?) = mutableListOf("--coverage")
24+
// Pass the IDE-managed report path to the CLI (mirrors PhpUnit's createCoverageArguments) so Testo writes the Clover
25+
// XML exactly where the IDE reads it back. `targetCoverage` is the remote-mapped path derived from
26+
// CoverageEnabledConfiguration.getCoverageFilePath() by PhpCoverageRunner. Testo exposes `--coverage-clover=<file>`
27+
// (Symfony Console, VALUE_REQUIRED). Fall back to the bare `--coverage` when no path is provided.
28+
override fun createCoverageArguments(targetCoverage: String?) =
29+
if (targetCoverage.isNullOrEmpty()) mutableListOf("--coverage")
30+
else mutableListOf("--coverage-clover=$targetCoverage")
2531

2632
override fun getRunnerId(): String = RUNNER_ID
2733

0 commit comments

Comments
 (0)