From 0def6fd000696fc470a972cde9a601afc9be5873 Mon Sep 17 00:00:00 2001 From: "Ilya.Kazakevich" Date: Thu, 19 Sep 2024 21:04:18 +0200 Subject: [PATCH] Python: Allow access python roots in tests. On TC you are only allowed to access certain directories (temp dir, project roots and so on). Some services might also access Python interpreter folders (to index python libs for example), hence we allow this too to prevent exceptions GitOrigin-RevId: 8f8bf13f859e9cf69ab424b8692968a18aa537cc --- python/testSrc/com/jetbrains/env/PyEnvTestSettings.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/python/testSrc/com/jetbrains/env/PyEnvTestSettings.kt b/python/testSrc/com/jetbrains/env/PyEnvTestSettings.kt index aeea862a4c83..52db22dc5353 100644 --- a/python/testSrc/com/jetbrains/env/PyEnvTestSettings.kt +++ b/python/testSrc/com/jetbrains/env/PyEnvTestSettings.kt @@ -1,8 +1,12 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.jetbrains.env +import com.intellij.openapi.application.ApplicationManager +import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess import com.intellij.testFramework.UsefulTestCase.IS_UNDER_TEAMCITY import com.intellij.util.SystemProperties +import com.jetbrains.env.PyEnvTestSettings.Companion.PATH_TO_TEST_ENV_PYTHON_INTERPRETERS +import com.jetbrains.env.PyTestEnvVars.entries import org.jetbrains.annotations.ApiStatus import org.jetbrains.annotations.TestOnly import java.io.File @@ -25,6 +29,12 @@ internal data class PyEnvTestSettings( ) { private val foldersWithPythons: List = listOfNotNull(folderWithCPythons, folderWithCondas).map { File(it) } + init { + // These files might be accessed in tests either directly or via symlinks created by venv + val roots = (foldersWithPythons + (additionalInterpreters.map { it.parentFile })).map { it.toString() }.toTypedArray() + VfsRootAccess.allowRootAccess(ApplicationManager.getApplication(), *roots) + } + /** * Paths to all existing python SDKs */