Skip to content

Commit 41a92d0

Browse files
vlegchilkinintellij-monorepo-bot
authored andcommitted
PY-60410 fix hatch cli tests (Hatch has changed own outputs in the latest release)
(cherry picked from commit f081174af88b806fa47c2aa579612635ecd672e8) IJ-MR-189128 GitOrigin-RevId: c365d16b019b17e21d53b5f87d5cb4fc1f8cd8d6
1 parent 08ffced commit 41a92d0

2 files changed

Lines changed: 4 additions & 3 deletions

File tree

python/python-hatch/src/com/intellij/python/hatch/cli/HatchCli.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import com.jetbrains.python.errorProcessing.PyResult
1515
import io.github.z4kn4fein.semver.Version
1616
import io.github.z4kn4fein.semver.VersionFormatException
1717
import java.io.IOException
18+
import java.nio.file.InvalidPathException
1819
import java.nio.file.Path
1920

2021
/**
@@ -189,7 +190,7 @@ class HatchCli(private val runtime: HatchRuntime) {
189190
try {
190191
Result.success(HatchStatus(project, Path.of(location), Path.of(config)))
191192
}
192-
catch (e: Exception) {
193+
catch (e: InvalidPathException) {
193194
Result.failure(e.localizedMessage)
194195
}
195196
}
@@ -224,7 +225,7 @@ class HatchCli(private val runtime: HatchRuntime) {
224225
* @return OldVersion to NewVersion as Pair
225226
*/
226227
suspend fun setVersion(desiredVersion: String): PyResult<Pair<Version, Version>> {
227-
val expectedOutput = """^Old: (.*)\nNew: (.*)\n$""".toRegex()
228+
val expectedOutput = """^(?:.*\n)*Old: (.*)\nNew: (.*)\n?$""".toRegex()
228229

229230
return runtime.executeAndMatch("version", desiredVersion, expectedOutput = expectedOutput, outputContentSupplier = { it.stderrString }) { matchResult ->
230231
val (oldVersion, newVersion) = matchResult.destructured

python/python-hatch/src/com/intellij/python/hatch/cli/HatchEnv.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const val ENV_TYPE_VIRTUAL: String = "virtual"
116116
*/
117117
class HatchEnv(runtime: HatchRuntime) : HatchCommand("env", runtime) {
118118
companion object {
119-
private val SHOW_RESPONSE_REGEX = """^\s+Standalone\s*\n((?:[+|].*[+|]\n)+)(?:\s+Matrices\s*\n((?:[+|].*[+|]\n)+))?$""".toRegex()
119+
private val SHOW_RESPONSE_REGEX = """^\s*Standalone\s*\n((?:[+|].*[+|]\n)+)(?:\s+Matrices\s*\n((?:[+|].*[+|]\n)+))?$""".toRegex()
120120
}
121121

122122
enum class CreateResult {

0 commit comments

Comments
 (0)