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
This commit is contained in:
Ilya.Kazakevich
2024-09-19 21:04:18 +02:00
committed by intellij-monorepo-bot
parent de3ca424da
commit 0def6fd000

View File

@@ -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<File> = 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
*/