Minor, untangle Multi(Module)HighlightingTest hierarchy a bit

This commit is contained in:
Pavel V. Talanov
2017-06-07 11:55:13 +03:00
parent 850568b8e9
commit 7949d3209b
9 changed files with 40 additions and 59 deletions
@@ -26,7 +26,7 @@ import org.jetbrains.kotlin.test.InTextDirectivesUtils
abstract class AbstractFindUsagesMultiModuleTest : AbstractMultiModuleTest() {
override val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleFindUsages/"
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleFindUsages/"
protected fun doFindUsagesTest() {
val allFilesInProject = PluginJetFilesProvider.allFilesInProject(myProject!!)
@@ -21,12 +21,21 @@ import org.jetbrains.kotlin.codegen.forTestCompile.ForTestCompileRuntime
import org.jetbrains.kotlin.config.TargetPlatformKind
import org.jetbrains.kotlin.idea.project.PluginJetFilesProvider
import org.jetbrains.kotlin.idea.stubs.AbstractMultiHighlightingTest
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
import org.junit.Assert
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(
vararg platforms: TargetPlatformKind<*>,
@@ -55,16 +64,4 @@ abstract class AbstractMultiModuleHighlightingTest : AbstractMultiHighlightingTe
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)
}
}
@@ -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
}
@@ -16,7 +16,11 @@
package org.jetbrains.kotlin.idea.caches.resolve
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
class Java8MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
fun testDifferentJdk() {
val module1 = module("jdk8", useFullJdk = true)
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.facet.KotlinFacetConfiguration
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.test.KotlinTestUtils
class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
open class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleHighlighting/"
override fun setUp() {
super.setUp()
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
@@ -142,7 +145,7 @@ class MultiModuleHighlightingTest : AbstractMultiModuleHighlightingTest() {
}
class MultiPlatform : AbstractMultiModuleHighlightingTest() {
override val testPath get() = super.testPath + "multiplatform/"
override fun getTestDataPath() = "${PluginTestCaseBase.getTestDataPathBase()}/multiModuleHighlighting/multiplatform/"
fun testBasic() {
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.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() {
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.editor.quickDoc.AbstractQuickDocProviderTest.wrapToFileComparisonFailure
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.psi.KtElement
import org.jetbrains.kotlin.resolve.BindingContext.DECLARATION_TO_DESCRIPTOR
@@ -34,8 +35,7 @@ import java.io.File
class KDocSampleTest : AbstractMultiModuleTest() {
override val testPath: String = "${super.testPath}/kdoc/multiModuleSamples/"
override fun getTestDataPath() = testPath
override fun getTestDataPath() = "${PluginTestCaseBase.getTestDataPathBase()}/kdoc/multiModuleSamples/"
override fun setUp() {
VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory())
@@ -90,7 +90,7 @@ class KDocSampleTest : AbstractMultiModuleTest() {
}
fun doInfoTest(path: String) {
val testDataFile = File(testPath, path)
val testDataFile = File(testDataPath, path)
configureByFile(path)
val documentationManager = DocumentationManager.getInstance(myProject)
val targetElement = documentationManager.findTargetElement(myEditor, file)
@@ -38,9 +38,7 @@ import java.util.regex.Pattern
abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest() {
override val testPath = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleQuickFix/"
override fun getTestDataPath() = testPath
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleQuickFix/"
protected fun shouldBeAvailableAfterExecution(file: KtFile) =
InTextDirectivesUtils.isDirectiveDefined(file.text, "// SHOULD_BE_AVAILABLE_AFTER_EXECUTION")
@@ -74,8 +72,8 @@ abstract class AbstractQuickFixMultiModuleTest : AbstractMultiModuleTest() {
doAction(text, actionShouldBeAvailable, actionFileName, actionFile)
if (actionShouldBeAvailable) {
val testDirectory = File(testPath)
val projectDirectory = File("$testPath${getTestName(true)}")
val testDirectory = File(testDataPath)
val projectDirectory = File("$testDataPath${getTestName(true)}")
for (moduleDirectory in projectDirectory.listFiles()) {
for (file in moduleDirectory.walkTopDown()) {
if (!file.path.endsWith(".after")) continue
@@ -42,10 +42,10 @@ import java.io.File
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 {
val srcDir = testPath + "${getTestName(true)}/$name"
val srcDir = testDataPath + "${getTestName(true)}/$name"
val moduleWithSrcRootSet = createModuleFromTestData(srcDir, name, StdModuleTypes.JAVA, true)!!
if (hasTestRoot) {
setTestRoot(moduleWithSrcRootSet, name)
@@ -58,7 +58,7 @@ abstract class AbstractMultiModuleTest : DaemonAnalyzerTestCase() {
}
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 testRootDir = createTempDirectory()!!
FileUtil.copyDir(testRootDirInTestData, testRootDir)