in src/main/kotlin/com/pestphp/pest/configuration/PestRerunFailedTestsAction.kt [36:93]
override fun getState(executor: Executor, environment: ExecutionEnvironment): RunProfileState? {
val peerRunConfiguration = this.peer as PestRunConfiguration
val project = peerRunConfiguration.project
val interpreter = peerRunConfiguration.interpreter ?: return null
val failed = getFailedTests(project)
.asSequence()
.filter { it.isLeaf }
.filter { it.parent != null }
.map { it.getLocation(project, GlobalSearchScope.allScope(project)) }
.mapNotNull { it?.psiElement }
.filter { it.isPestTestReference() }
.toList()
val clone: PestRunConfiguration = peerRunConfiguration.clone() as PestRunConfiguration
// If there are no failed tests found, it's prob.
// because it's an pest version before the new printer
if (failed.isEmpty()) {
OutdatedNotification().notify(
project,
PestBundle.message("NO_FAILED_TESTS_FOUND")
)
return peerRunConfiguration.getState(
environment,
clone.createCommand(
interpreter,
mutableMapOf(),
mutableListOf(),
false
),
null
)
}
val command: PhpCommandSettings = clone.createCommand(
interpreter,
mutableMapOf(),
getArgumentsFromRunner(environment.runner),
false
)
val rootPath = ComposerConfigManager.getInstance(project).getConfig(null as PsiElement?)?.parent?.path ?: command.workingDirectory
val testcases = failed.mapNotNull { it.toPestTestRegex(rootPath) }
.reduce { result, testName -> "$result|$testName" }
command.addArgument(
"--filter=/$testcases/"
)
return peerRunConfiguration.getState(
environment,
command,
null
)
}