PY-60410 fix hatch cli tests (Hatch has changed own outputs in the latest release)

GitOrigin-RevId: fba9e2ee1afeded13044e7a08602eb71270d9ab9
This commit is contained in:
Vitaly Legchilkin
2026-01-26 15:06:41 +00:00
committed by intellij-monorepo-bot
parent 198ad2af6f
commit b1b1d701bc
2 changed files with 4 additions and 3 deletions
@@ -15,6 +15,7 @@ import com.jetbrains.python.errorProcessing.PyResult
import io.github.z4kn4fein.semver.Version
import io.github.z4kn4fein.semver.VersionFormatException
import java.io.IOException
import java.nio.file.InvalidPathException
import java.nio.file.Path
/**
@@ -189,7 +190,7 @@ class HatchCli(private val runtime: HatchRuntime) {
try {
Result.success(HatchStatus(project, Path.of(location), Path.of(config)))
}
catch (e: Exception) {
catch (e: InvalidPathException) {
Result.failure(e.localizedMessage)
}
}
@@ -224,7 +225,7 @@ class HatchCli(private val runtime: HatchRuntime) {
* @return OldVersion to NewVersion as Pair
*/
suspend fun setVersion(desiredVersion: String): PyResult<Pair<Version, Version>> {
val expectedOutput = """^Old: (.*)\nNew: (.*)\n$""".toRegex()
val expectedOutput = """^(?:.*\n)*Old: (.*)\nNew: (.*)\n?$""".toRegex()
return runtime.executeAndMatch("version", desiredVersion, expectedOutput = expectedOutput, outputContentSupplier = { it.stderrString }) { matchResult ->
val (oldVersion, newVersion) = matchResult.destructured
@@ -116,7 +116,7 @@ const val ENV_TYPE_VIRTUAL: String = "virtual"
*/
class HatchEnv(runtime: HatchRuntime) : HatchCommand("env", runtime) {
companion object {
private val SHOW_RESPONSE_REGEX = """^\s+Standalone\s*\n((?:[+|].*[+|]\n)+)(?:\s+Matrices\s*\n((?:[+|].*[+|]\n)+))?$""".toRegex()
private val SHOW_RESPONSE_REGEX = """^\s*Standalone\s*\n((?:[+|].*[+|]\n)+)(?:\s+Matrices\s*\n((?:[+|].*[+|]\n)+))?$""".toRegex()
}
enum class CreateResult {