Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

- Starting a mutation run no longer reads the coverage report on the UI thread.
- OpenIDE: a Coverage run says why it could not check for Xdebug or PCOV, and refuses to start when PHP cannot be started at all.
- *Run with Mutation* on a *Rerun Failed Tests* tab, and rerunning such a run from Test History, run the failed tests only instead of the whole suite.

## [2026.18] - 2026-11-27

Expand Down
24 changes: 12 additions & 12 deletions src/main/kotlin/com/github/xepozz/testo/runs/TestoRunArchiver.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ internal object TestoRunArchiver {
configurationName = recording.configurationName,
executorId = recording.executorId,
commandLine = props.commandLine.orEmpty(),
configuration = serializeConfiguration(props),
startedAt = recording.startedAt,
finishedAt = finishedAt,
workingDirectory = props.workingDirectory.orEmpty(),
Expand All @@ -93,7 +92,7 @@ internal object TestoRunArchiver {
interpreterType = configuration?.interpreterKind.orEmpty(),
pluginVersion = pluginVersion(),
testoVersion = props.testoVersion.orEmpty(),
)
).withConfiguration(configuration)
recording.writeManifest(manifest)
TestoRunStore.getInstance(project).prune()
// The archive is the lens's whole source of truth, and it only just became complete — so the lens is
Expand Down Expand Up @@ -154,17 +153,18 @@ internal object TestoRunArchiver {
(javaClass.classLoader as? PluginAwareClassLoader)?.pluginDescriptor?.version.orEmpty()

/**
* The run configuration as XML — the same form the IDE persists it in, so a replay can restore it and rerun the
* real thing. Empty when this console is not backed by a Testo configuration (nothing to rerun then).
* [configuration] as the IDE persists it, so a replay can restore it and rerun the real thing, plus the rerun
* filters that form leaves out. Unchanged when the console is not backed by a Testo configuration.
*/
private fun serializeConfiguration(props: TestoConsoleProperties): String =
(props.configuration as? TestoConfiguration)?.let { configuration ->
runCatching {
val element = Element("configuration")
configuration.writeExternal(element)
JDOMUtil.write(element)
}.onFailure { LOG.warn("Failed to serialize the Testo run configuration", it) }.getOrNull()
}.orEmpty()
fun TestoRunManifest.withConfiguration(configuration: TestoConfiguration?): TestoRunManifest {
if (configuration == null) return this
val xml = runCatching {
val element = Element("configuration")
configuration.writeExternal(element)
JDOMUtil.write(element)
}.onFailure { LOG.warn("Failed to serialize the Testo run configuration", it) }.getOrNull().orEmpty()
return copy(configuration = xml, rerunFilters = configuration.selection.rerunFilters)
}

/**
* Copies one report into the run's `reports/`, and returns the run-dir-relative path of its **entry** (what the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ data class TestoRunManifest(
val commandLine: String = "",
/** The run configuration as XML (`RunConfiguration.writeExternal`), so a replayed tab can rerun the real thing. */
val configuration: String = "",
/** A "Rerun Failed Tests" run's `--filter`s, which [configuration] never carries. */
val rerunFilters: List<String> = emptyList(),
val startedAt: Long = 0,
val finishedAt: Long = 0,
val workingDirectory: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ internal fun restoreTestoConfiguration(project: Project, runDir: Path, manifest:
runCatching { configuration.readExternal(JDOMUtil.load(xml)) }
.onFailure { Logger.getInstance(TestoRunReplayProfile::class.java).warn("Failed to restore the run configuration of $runDir", it) }
}
if (manifest.rerunFilters.isNotEmpty()) {
configuration.selection = configuration.selection.copy(rerunFilters = manifest.rerunFilters)
}
configuration.name = manifest.configurationName.ifEmpty { runDir.fileName.toString() }
return configuration
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@ class TestoMutationProgramRunner : TestoCoverageProgramRunner() {
override fun canRun(executorId: String, profile: RunProfile): Boolean =
executorId == TestoMutationExecutor.ID && profile is TestoRunConfiguration

override fun prepare(configuration: TestoRunConfiguration): TestoRunConfiguration =
// clone() goes through writeExternal, which leaves out a "Rerun Failed Tests" run's transient filters.
public override fun prepare(configuration: TestoRunConfiguration): TestoRunConfiguration =
(configuration.clone() as TestoRunConfiguration).apply {
testoSettings.runnerSettings.coverageXml = true
testoSettings.runnerSettings.logJunit = true
testoSettings.runnerSettings.rerunFilters = configuration.testoSettings.runnerSettings.rerunFilters
}

override fun started(env: ExecutionEnvironment, properties: TestoConsoleProperties) = mutateAfterArchive(env, properties)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.github.xepozz.testo.phpstorm.coverage

import com.github.xepozz.testo.phpstorm.tests.run.TestoRunConfiguration
import com.github.xepozz.testo.phpstorm.tests.run.TestoRunConfigurationType
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import com.jetbrains.php.testFramework.run.PhpTestRunnerSettings

class TestoMutationProgramRunnerTest : BasePlatformTestCase() {
fun testMutatingARerunOfFailedTestsKeepsItsFilters() {
val rerun = TestoRunConfigurationType.INSTANCE.createTemplateConfiguration(project) as TestoRunConfiguration
rerun.testoSettings.runnerSettings.apply {
rerunFilters = listOf("\\App\\CalcTest::sum")
scope = PhpTestRunnerSettings.Scope.ConfigurationFile
}

val mutated = TestoMutationProgramRunner().prepare(rerun).testoSettings.runnerSettings

assertEquals(listOf("\\App\\CalcTest::sum"), mutated.rerunFilters)
assertEquals(PhpTestRunnerSettings.Scope.ConfigurationFile, mutated.scope)
assertTrue(mutated.coverageXml)
assertTrue(mutated.logJunit)
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
package com.github.xepozz.testo.php

import com.github.xepozz.testo.launch.TestoConfiguration
import com.github.xepozz.testo.runs.TestoRunArchiver
import com.github.xepozz.testo.runs.TestoRunManifest
import com.github.xepozz.testo.runs.restoreTestoConfiguration
import com.intellij.openapi.command.WriteCommandAction
import com.intellij.openapi.util.io.FileUtil
import com.intellij.psi.PsiDocumentManager
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.testFramework.fixtures.BasePlatformTestCase
import java.nio.file.Path

/**
* What the plugin relies on from a PHP implementation, asked through [TestoPhp] only — the same questions any
Expand Down Expand Up @@ -309,4 +313,16 @@ class TestoPhpContractTest : BasePlatformTestCase() {
assertInstanceOf(factory.createTemplateConfiguration(project), TestoConfiguration::class.java)
assertEquals("The type id saved configurations carry", "TestoRunConfiguration", factory.type.id)
}

fun testAReplayKeepsTheRerunFiltersTheSavedConfigurationDrops() {
val rerun = (php.configurationFactory().createTemplateConfiguration(project) as TestoConfiguration).apply {
selection = selection.copy(rerunFilters = listOf("\\App\\CalcTest::sum"))
}
val manifest = with(TestoRunArchiver) { TestoRunManifest().withConfiguration(rerun) }

val restored = restoreTestoConfiguration(project, Path.of("run"), manifest)

assertFalse("Saved configurations stay free of the filters", manifest.configuration.contains("CalcTest"))
assertEquals(listOf("\\App\\CalcTest::sum"), restored.selection.rerunFilters)
}
}
Loading