From a45cc17b1cf04a8766a967fd1e3e71ba7f61a778 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Thu, 7 Apr 2022 15:17:21 +0400 Subject: [PATCH] [Test] Provide utility for registering idea properties for proper test run In Kotlin project they are set up automatically, but outside they should be set manually via build system or test framework --- .../jetbrains/kotlin/test/TestSetupUtils.kt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 compiler/tests-common-new/tests/org/jetbrains/kotlin/test/TestSetupUtils.kt diff --git a/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/TestSetupUtils.kt b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/TestSetupUtils.kt new file mode 100644 index 00000000000..940cd990d26 --- /dev/null +++ b/compiler/tests-common-new/tests/org/jetbrains/kotlin/test/TestSetupUtils.kt @@ -0,0 +1,24 @@ +/* + * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.kotlin.test + +import java.io.File + +/** + * For proper initialization of idea services those two properties should + * be set in environment of test. You can setup them manually via build + * system of run configurations or just `initIdeaConfiguration` before + * running tests using abilities of core test framework you use + */ +fun initIdeaConfiguration() { + System.setProperty("idea.home", computeHomeDirectory()) + System.setProperty("idea.ignore.disabled.plugins", "true") +} + +private fun computeHomeDirectory(): String { + val userDir = System.getProperty("user.dir") + return File(userDir ?: ".").canonicalPath +}