From baf30ce79aec758010ad87a271dd1e25c8e8f9ee Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Wed, 2 Apr 2025 19:21:57 +0200 Subject: [PATCH] Python tests: timeout increased (venv might be slow on some agents) GitOrigin-RevId: 49cb95c758ce51743e8e1c4c67b79f20b19ceef4 --- .../src/com/intellij/internal/InternalUtil.kt | 3 +++ .../intellij/python/community/impl/venv/venv.kt | 4 +++- .../SystemPythonServiceShowCaseTest.kt | 17 +++++++++++------ 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/platform/platform-impl/internal/src/com/intellij/internal/InternalUtil.kt b/platform/platform-impl/internal/src/com/intellij/internal/InternalUtil.kt index 903f6b96da10..cfd34d1d695e 100644 --- a/platform/platform-impl/internal/src/com/intellij/internal/InternalUtil.kt +++ b/platform/platform-impl/internal/src/com/intellij/internal/InternalUtil.kt @@ -43,5 +43,8 @@ private fun openInIdeaProject(project: Project?, module: Module, fileName: Strin return true } } + + val a: Project = null!! + a.basePath return false } diff --git a/python/python-venv/src/com/intellij/python/community/impl/venv/venv.kt b/python/python-venv/src/com/intellij/python/community/impl/venv/venv.kt index ceaab1ef0cbe..4be91d02c279 100644 --- a/python/python-venv/src/com/intellij/python/community/impl/venv/venv.kt +++ b/python/python-venv/src/com/intellij/python/community/impl/venv/venv.kt @@ -3,6 +3,7 @@ package com.intellij.python.community.impl.venv import com.intellij.openapi.application.EDT import com.intellij.openapi.diagnostic.fileLogger +import com.intellij.python.community.execService.ExecOptions import com.intellij.python.community.execService.ExecService import com.intellij.python.community.execService.HelperName import com.intellij.python.community.execService.WhatToExec @@ -21,6 +22,7 @@ import org.jetbrains.annotations.ApiStatus.Internal import org.jetbrains.annotations.CheckReturnValue import java.nio.file.Path import kotlin.io.path.pathString +import kotlin.time.Duration.Companion.minutes /** * Create virtual env in [venvDir] using [python]. @@ -45,7 +47,7 @@ suspend fun createVenv( } val version = python.validatePythonAndGetVersion().getOr { return failure(it.error) } val helper = if (version.isPy3K) VIRTUALENV_ZIPAPP_NAME else PY_2_VIRTUALENV_ZIPAPP_NAME - execService.execGetStdout(WhatToExec.Helper(python, helper = helper), args).getOr { return it } + execService.execGetStdout(WhatToExec.Helper(python, helper = helper), args, ExecOptions(timeout = 3.minutes)).getOr { return it } val venvPython = withContext(Dispatchers.IO) { diff --git a/python/services/system-python/tests/com/intellij/python/junit5Tests/env/systemPython/SystemPythonServiceShowCaseTest.kt b/python/services/system-python/tests/com/intellij/python/junit5Tests/env/systemPython/SystemPythonServiceShowCaseTest.kt index f1f2bc7d590c..9dbefa230084 100644 --- a/python/services/system-python/tests/com/intellij/python/junit5Tests/env/systemPython/SystemPythonServiceShowCaseTest.kt +++ b/python/services/system-python/tests/com/intellij/python/junit5Tests/env/systemPython/SystemPythonServiceShowCaseTest.kt @@ -44,7 +44,7 @@ import kotlin.time.Duration.Companion.minutes class SystemPythonServiceShowCaseTest { @Test - fun testListPythons(): Unit = timeoutRunBlocking { + fun testListPythons(): Unit = timeoutRunBlocking(10.minutes) { for (systemPython in SystemPythonService().findSystemPythons(forceRefresh = true)) { fileLogger().info("Python found: $systemPython") val eelApi = systemPython.pythonBinary.getEelDescriptor().upgrade() @@ -59,18 +59,23 @@ class SystemPythonServiceShowCaseTest { } @Test - fun testCustomPythonRainyDay(): Unit = timeoutRunBlocking { + fun testCustomPythonRainyDay(): Unit = timeoutRunBlocking(10.minutes) { SystemPythonService().registerSystemPython(randomBinary).assertFail() } @Test - fun testCustomPythonSunnyDay(@PythonBinaryPath python: Path, @TempDir venvPath: Path): Unit = timeoutRunBlocking { + fun testCustomPythonSunnyDay(@PythonBinaryPath python: Path, @TempDir venvPath: Path): Unit = timeoutRunBlocking(10.minutes) { createVenv(python, venvPath).getOrThrow() val python = VirtualEnvReader.Instance.findPythonInPythonRoot(venvPath) ?: error("no python in $venvPath") val newPython = SystemPythonService().registerSystemPython(python).orThrow() var allPythons = SystemPythonService().findSystemPythons() assertThat("No newly registered python returned", allPythons, hasItem(newPython)) - python.deleteExisting() + if (SystemInfo.isWindows) { + deleteCheckLocking(python) + } + else { + python.deleteExisting() + } allPythons = SystemPythonService().findSystemPythons(forceRefresh = true) assertThat("Broken python returned", allPythons, not(hasItem(newPython))) @@ -81,7 +86,7 @@ class SystemPythonServiceShowCaseTest { } @Test - fun testRefresh(@TestDisposable disposable: Disposable): Unit = timeoutRunBlocking { + fun testRefresh(@TestDisposable disposable: Disposable): Unit = timeoutRunBlocking(10.minutes) { val mockProvider = mockk() coEvery { mockProvider.findSystemPythons(any()) } returns Result.failure(java.lang.AssertionError("...")) coEvery { mockProvider.uiCustomization } returns null @@ -98,7 +103,7 @@ class SystemPythonServiceShowCaseTest { @RegistryKey("python.system.refresh.minutes", "0") @Test - fun testDisableCache(@TestDisposable disposable: Disposable): Unit = timeoutRunBlocking { + fun testDisableCache(@TestDisposable disposable: Disposable): Unit = timeoutRunBlocking(10.minutes) { val timesToRepeat = 5 val mockProvider = mockk() coEvery { mockProvider.findSystemPythons(any()) } returns Result.success(emptySet())