Minor, untangle Multi(Module)HighlightingTest hierarchy a bit
This commit is contained in:
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
|||||||
|
|
||||||
abstract class AbstractFindUsagesMultiModuleTest : AbstractMultiModuleTest() {
|
abstract class AbstractFindUsagesMultiModuleTest : AbstractMultiModuleTest() {
|
||||||
|
|
||||||
override val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleFindUsages/"
|
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleFindUsages/"
|
||||||
|
|
||||||
protected fun doFindUsagesTest() {
|
protected fun doFindUsagesTest() {
|
||||||
val allFilesInProject = PluginJetFilesProvider.allFilesInProject(myProject!!)
|
val allFilesInProject = PluginJetFilesProvider.allFilesInProject(myProject!!)
|
||||||
|
|||||||
+11
-14
@@ -21,12 +21,21 @@ import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
|
|||||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||||
import org.jetbrains.kotlin.idea.project.PluginJetFilesProvider
|
import org.jetbrains.kotlin.idea.project.PluginJetFilesProvider
|
||||||
import org.jetbrains.kotlin.idea.stubs.AbstractMultiHighlightingTest
|
import org.jetbrains.kotlin.idea.stubs.AbstractMultiHighlightingTest
|
||||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
|
|
||||||
abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTest() {
|
abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTest() {
|
||||||
|
|
||||||
override val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
|
protected fun checkHighlightingInAllFiles(nameFilter: (fileName: String) -> Boolean = { true }) {
|
||||||
|
var atLeastOneFile = false
|
||||||
|
PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file ->
|
||||||
|
if (nameFilter(file.name) && !file.text.contains("// !CHECK_HIGHLIGHTING")) {
|
||||||
|
atLeastOneFile = true
|
||||||
|
configureByExistingFile(file.virtualFile!!)
|
||||||
|
checkHighlighting(myEditor, true, false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Assert.assertTrue(atLeastOneFile)
|
||||||
|
}
|
||||||
|
|
||||||
protected fun doMultiPlatformTest(
|
protected fun doMultiPlatformTest(
|
||||||
vararg platforms: TargetPlatformKind<*>,
|
vararg platforms: TargetPlatformKind<*>,
|
||||||
@@ -55,16 +64,4 @@ abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTe
|
|||||||
|
|
||||||
checkHighlightingInAllFiles()
|
checkHighlightingInAllFiles()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected fun checkHighlightingInAllFiles(nameFilter: (fileName: String) -> Boolean = { true }) {
|
|
||||||
var atLeastOneFile = false
|
|
||||||
PluginJetFilesProvider.allFilesInProject(myProject!!).forEach { file ->
|
|
||||||
if (nameFilter(file.name) && !file.text.contains("// !CHECK_HIGHLIGHTING")) {
|
|
||||||
atLeastOneFile = true
|
|
||||||
configureByExistingFile(file.virtualFile!!)
|
|
||||||
checkHighlighting(myEditor, true, false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Assert.assertTrue(atLeastOneFile)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2016 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.caches.resolve
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
|
||||||
|
|
||||||
abstract class AbstractMultiModuleLineMarkerTest : AbstractMultiModuleHighlightingTest() {
|
|
||||||
|
|
||||||
override val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleLineMarker/"
|
|
||||||
|
|
||||||
override val shouldCheckLineMarkers = true
|
|
||||||
|
|
||||||
override val shouldCheckResult = false
|
|
||||||
|
|
||||||
override fun doTestLineMarkers() = true
|
|
||||||
}
|
|
||||||
+4
@@ -16,7 +16,11 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.caches.resolve
|
package org.jetbrains.kotlin.idea.caches.resolve
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
|
|
||||||
class Java8MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
class Java8MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
||||||
|
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
|
||||||
|
|
||||||
fun testDifferentJdk() {
|
fun testDifferentJdk() {
|
||||||
val module1 = module("jdk8", useFullJdk = true)
|
val module1 = module("jdk8", useFullJdk = true)
|
||||||
val module2 = module("mockJdk")
|
val module2 = module("mockJdk")
|
||||||
|
|||||||
@@ -30,10 +30,13 @@ import org.jetbrains.kotlin.config.TargetPlatformKind
|
|||||||
import org.jetbrains.kotlin.idea.completion.test.withServiceRegistered
|
import org.jetbrains.kotlin.idea.completion.test.withServiceRegistered
|
||||||
import org.jetbrains.kotlin.idea.facet.KotlinFacetConfiguration
|
import org.jetbrains.kotlin.idea.facet.KotlinFacetConfiguration
|
||||||
import org.jetbrains.kotlin.idea.facet.KotlinFacetType
|
import org.jetbrains.kotlin.idea.facet.KotlinFacetType
|
||||||
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
|
|
||||||
class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
open class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
||||||
|
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
|
||||||
|
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
super.setUp()
|
super.setUp()
|
||||||
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
|
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||||
@@ -142,7 +145,7 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MultiPlatform : AbstractMultiModuleHighlightingTest() {
|
class MultiPlatform : AbstractMultiModuleHighlightingTest() {
|
||||||
override val testPath get() = super.testPath + "multiplatform/"
|
override fun getTestDataPath() = "${PluginTestCaseBase.getTestDataPathBase()}/multiModuleHighlighting/multiplatform/"
|
||||||
|
|
||||||
fun testBasic() {
|
fun testBasic() {
|
||||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
|
|||||||
@@ -18,8 +18,17 @@ package org.jetbrains.kotlin.idea.caches.resolve
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.config.JvmTarget
|
import org.jetbrains.kotlin.config.JvmTarget
|
||||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||||
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
|
|
||||||
class MultiModuleLineMarkerTest : AbstractMultiModuleLineMarkerTest() {
|
class MultiModuleLineMarkerTest : AbstractMultiModuleHighlightingTest() {
|
||||||
|
|
||||||
|
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleLineMarker/"
|
||||||
|
|
||||||
|
override val shouldCheckLineMarkers = true
|
||||||
|
|
||||||
|
override val shouldCheckResult = false
|
||||||
|
|
||||||
|
override fun doTestLineMarkers() = true
|
||||||
|
|
||||||
fun testFromCommonToJvmHeader() {
|
fun testFromCommonToJvmHeader() {
|
||||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
|||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
import org.jetbrains.kotlin.idea.editor.quickDoc.AbstractQuickDocProviderTest.wrapToFileComparisonFailure
|
import org.jetbrains.kotlin.idea.editor.quickDoc.AbstractQuickDocProviderTest.wrapToFileComparisonFailure
|
||||||
import org.jetbrains.kotlin.idea.stubs.AbstractMultiModuleTest
|
import org.jetbrains.kotlin.idea.stubs.AbstractMultiModuleTest
|
||||||
|
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||||
import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection
|
import org.jetbrains.kotlin.kdoc.psi.impl.KDocSection
|
||||||
import org.jetbrains.kotlin.psi.KtElement
|
import org.jetbrains.kotlin.psi.KtElement
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext.DECLARATION_TO_DESCRIPTOR
|
import org.jetbrains.kotlin.resolve.BindingContext.DECLARATION_TO_DESCRIPTOR
|
||||||
@@ -34,8 +35,7 @@ import java.io.File
|
|||||||
|
|
||||||
class KDocSampleTest : AbstractMultiModuleTest() {
|
class KDocSampleTest : AbstractMultiModuleTest() {
|
||||||
|
|
||||||
override val testPath: String = "${super.testPath}/kdoc/multiModuleSamples/"
|
override fun getTestDataPath() = "${PluginTestCaseBase.getTestDataPathBase()}/kdoc/multiModuleSamples/"
|
||||||
override fun getTestDataPath() = testPath
|
|
||||||
|
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
|
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
|
||||||
@@ -90,7 +90,7 @@ class KDocSampleTest : AbstractMultiModuleTest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun doInfoTest(path: String) {
|
fun doInfoTest(path: String) {
|
||||||
val testDataFile = File(testPath, path)
|
val testDataFile = File(testDataPath, path)
|
||||||
configureByFile(path)
|
configureByFile(path)
|
||||||
val documentationManager = DocumentationManager.getInstance(myProject)
|
val documentationManager = DocumentationManager.getInstance(myProject)
|
||||||
val targetElement = documentationManager.findTargetElement(myEditor, file)
|
val targetElement = documentationManager.findTargetElement(myEditor, file)
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ import java.util.regex.Pattern
|
|||||||
|
|
||||||
abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest() {
|
abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest() {
|
||||||
|
|
||||||
override val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleQuickFix/"
|
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleQuickFix/"
|
||||||
|
|
||||||
override fun getTestDataPath() = testPath
|
|
||||||
|
|
||||||
protected fun shouldBeAvailableAfterExecution(file: KtFile) =
|
protected fun shouldBeAvailableAfterExecution(file: KtFile) =
|
||||||
InTextDirectivesUtils.isDirectiveDefined(file.text, "// SHOULD_BE_AVAILABLE_AFTER_EXECUTION")
|
InTextDirectivesUtils.isDirectiveDefined(file.text, "// SHOULD_BE_AVAILABLE_AFTER_EXECUTION")
|
||||||
@@ -74,8 +72,8 @@ abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest() {
|
|||||||
doAction(text, actionShouldBeAvailable, actionFileName, actionFile)
|
doAction(text, actionShouldBeAvailable, actionFileName, actionFile)
|
||||||
|
|
||||||
if (actionShouldBeAvailable) {
|
if (actionShouldBeAvailable) {
|
||||||
val testDirectory = File(testPath)
|
val testDirectory = File(testDataPath)
|
||||||
val projectDirectory = File("$testPath${getTestName(true)}")
|
val projectDirectory = File("$testDataPath${getTestName(true)}")
|
||||||
for (moduleDirectory in projectDirectory.listFiles()) {
|
for (moduleDirectory in projectDirectory.listFiles()) {
|
||||||
for (file in moduleDirectory.walkTopDown()) {
|
for (file in moduleDirectory.walkTopDown()) {
|
||||||
if (!file.path.endsWith(".after")) continue
|
if (!file.path.endsWith(".after")) continue
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ import java.io.File
|
|||||||
|
|
||||||
abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() {
|
abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() {
|
||||||
|
|
||||||
protected open val testPath = PluginTestCaseBase.getTestDataPathBase()
|
abstract override fun getTestDataPath(): String
|
||||||
|
|
||||||
protected fun module(name: String, hasTestRoot: Boolean = false, useFullJdk: Boolean = false): Module {
|
protected fun module(name: String, hasTestRoot: Boolean = false, useFullJdk: Boolean = false): Module {
|
||||||
val srcDir = testPath + "${getTestName(true)}/$name"
|
val srcDir = testDataPath + "${getTestName(true)}/$name"
|
||||||
val moduleWithSrcRootSet = createModuleFromTestData(srcDir, name, StdModuleTypes.JAVA, true)!!
|
val moduleWithSrcRootSet = createModuleFromTestData(srcDir, name, StdModuleTypes.JAVA, true)!!
|
||||||
if (hasTestRoot) {
|
if (hasTestRoot) {
|
||||||
setTestRoot(moduleWithSrcRootSet, name)
|
setTestRoot(moduleWithSrcRootSet, name)
|
||||||
@@ -58,7 +58,7 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun setTestRoot(module: Module, name: String) {
|
private fun setTestRoot(module: Module, name: String) {
|
||||||
val testDir = testPath + "${getTestName(true)}/${name}Test"
|
val testDir = testDataPath + "${getTestName(true)}/${name}Test"
|
||||||
val testRootDirInTestData = File(testDir)
|
val testRootDirInTestData = File(testDir)
|
||||||
val testRootDir = createTempDirectory()!!
|
val testRootDir = createTempDirectory()!!
|
||||||
FileUtil.copyDir(testRootDirInTestData, testRootDir)
|
FileUtil.copyDir(testRootDirInTestData, testRootDir)
|
||||||
|
|||||||
Reference in New Issue
Block a user