Tests: fix gradle tests for script configuration loading
Introduce `testAffectedGradleProjectFiles` property to avoid full gradle project import in some tests
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
/*
|
||||
* Copyright 2010-2020 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.idea.scripting.gradle
|
||||
|
||||
import com.intellij.openapi.application.Application
|
||||
|
||||
// this property is used in tests to avoid full gradle project import and to make those tests more lightweight
|
||||
var testAffectedGradleProjectFiles: Boolean = false
|
||||
|
||||
internal val Application.isUnitTestModeWithoutAffectedGradleProjectFilesCheck: Boolean
|
||||
get() {
|
||||
if (isUnitTestMode) {
|
||||
return !testAffectedGradleProjectFiles
|
||||
}
|
||||
return false
|
||||
}
|
||||
@@ -36,8 +36,9 @@ fun isInAffectedGradleProjectFiles(project: Project, filePath: String): Boolean
|
||||
}
|
||||
|
||||
fun isInAffectedGradleProjectFiles(files: Set<String>, filePath: String): Boolean {
|
||||
// todo: avoid isUnitTestMode usage
|
||||
if (ApplicationManager.getApplication().isUnitTestMode) return true
|
||||
if (ApplicationManager.getApplication().isUnitTestModeWithoutAffectedGradleProjectFilesCheck) {
|
||||
return true
|
||||
}
|
||||
|
||||
return filePath in files
|
||||
}
|
||||
|
||||
+7
-2
@@ -5,7 +5,6 @@
|
||||
|
||||
package org.jetbrains.kotlin.idea.scripting.gradle
|
||||
|
||||
import junit.framework.TestCase
|
||||
import org.jetbrains.kotlin.idea.core.script.ScriptConfigurationManager
|
||||
import org.jetbrains.kotlin.idea.script.AbstractScriptConfigurationLoadingTest
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
@@ -22,7 +21,13 @@ class GradleScriptOutOfProjectTest : AbstractScriptConfigurationLoadingTest() {
|
||||
|
||||
configureScriptFile(rootDir, buildGradleKts)
|
||||
|
||||
ScriptConfigurationManager.markFileWithManualConfigurationLoading(myFile.virtualFile)
|
||||
testAffectedGradleProjectFiles = true
|
||||
}
|
||||
|
||||
override fun tearDown() {
|
||||
super.tearDown()
|
||||
|
||||
testAffectedGradleProjectFiles = false
|
||||
}
|
||||
|
||||
private val loaderForOutOfProjectScripts by lazy {
|
||||
|
||||
Reference in New Issue
Block a user