From b25a5eedf05917a5503779eaa574cd2e2cb9dbd4 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Tue, 16 Jul 2024 20:38:55 +0200 Subject: [PATCH] Move `ensureCorrectVersion` to the shared module and reuse it with JUnit5. There also should be an error, not skip. Broken environment shouldn't pass silently. GitOrigin-RevId: 847fd28db1b809693acdef73a41b816f7fdcfb65 --- .../com/intellij/execution/wsl/WslRule.kt | 17 +----------- .../testFramework/WslTeamCityTestTool.kt | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 platform/testFramework/src/com/intellij/testFramework/WslTeamCityTestTool.kt diff --git a/platform/platform-tests/testSrc/com/intellij/execution/wsl/WslRule.kt b/platform/platform-tests/testSrc/com/intellij/execution/wsl/WslRule.kt index 27100a5a3d80..784ce7c18110 100644 --- a/platform/platform-tests/testSrc/com/intellij/execution/wsl/WslRule.kt +++ b/platform/platform-tests/testSrc/com/intellij/execution/wsl/WslRule.kt @@ -3,8 +3,8 @@ package com.intellij.execution.wsl import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.util.io.IoTestUtil +import com.intellij.testFramework.ensureCorrectVersion import org.junit.Assume.assumeTrue -import org.junit.jupiter.api.Assumptions import org.junit.rules.ExternalResource import java.io.IOException import kotlin.io.path.exists @@ -36,21 +36,6 @@ class WslFixture private constructor(val vms: List) { companion object { private val LOG = logger() - fun ensureCorrectVersion(wsl: WSLDistribution) { - System.getenv("WSL_VERSION")?.let { - if (it.toInt() != wsl.version) { - val error = """ - Variable provided by environment claims WSL is $it. - But wsl is ${wsl.version}. - Hence, environment provides wrong information. - With all of that, test can't continue. Fix your environment. - """.trimIndent() - logger().warn(error) - Assumptions.abort(error) - } - } - } - @JvmStatic fun create(assume: Boolean = true): WslFixture { if (assume) { diff --git a/platform/testFramework/src/com/intellij/testFramework/WslTeamCityTestTool.kt b/platform/testFramework/src/com/intellij/testFramework/WslTeamCityTestTool.kt new file mode 100644 index 000000000000..1e3f55f2755c --- /dev/null +++ b/platform/testFramework/src/com/intellij/testFramework/WslTeamCityTestTool.kt @@ -0,0 +1,26 @@ +// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.testFramework + +import com.intellij.execution.wsl.WSLDistribution +import com.intellij.openapi.diagnostic.Logger + +private val LOGGER = Logger.getInstance("WslTeamCityTestTool") + +/** + * Early failure for IJI-1731 + */ +fun ensureCorrectVersion(wsl: WSLDistribution) { + System.getenv("WSL_VERSION")?.let { // This var must be set on TC manually + if (it.toInt() != wsl.version) { + val error = """ + Variable provided by environment claims WSL is $it. + But wsl is ${wsl.version}. + Hence, environment provides wrong information. + With all of that, test can't continue. Fix your environment. + """.trimIndent() + LOGGER.error(error) + error(error) + } + } +} +