Rewrite mpp line marker tests to be generated
This commit is contained in:
@@ -52,6 +52,7 @@ import org.jetbrains.kotlin.idea.AbstractSmartSelectionTest
|
||||
import org.jetbrains.kotlin.idea.actions.AbstractGotoTestOrCodeActionTest
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.AbstractIdeCompiledLightClassTest
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.AbstractIdeLightClassTest
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.AbstractMultiModuleLineMarkerTest
|
||||
import org.jetbrains.kotlin.idea.codeInsight.*
|
||||
import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractCodeInsightActionTest
|
||||
import org.jetbrains.kotlin.idea.codeInsight.generate.AbstractGenerateHashCodeAndEqualsActionTest
|
||||
@@ -549,6 +550,10 @@ fun main(args: Array<String>) {
|
||||
model("codeInsight/lineMarker")
|
||||
}
|
||||
|
||||
testClass<AbstractMultiModuleLineMarkerTest> {
|
||||
model("multiModuleLineMarker", extension = null, recursive = false)
|
||||
}
|
||||
|
||||
testClass<AbstractShortenRefsTest> {
|
||||
model("shortenRefs", pattern = KT_WITHOUT_DOTS_IN_NAME)
|
||||
}
|
||||
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* 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.multiplatform.setupMppProjectFromDirStructure
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import java.io.File
|
||||
|
||||
abstract class AbstractMultiModuleLineMarkerTest : AbstractMultiModuleHighlightingTest() {
|
||||
|
||||
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleLineMarker/"
|
||||
|
||||
override val shouldCheckLineMarkers = true
|
||||
|
||||
override val shouldCheckResult = false
|
||||
|
||||
override fun doTestLineMarkers() = true
|
||||
|
||||
protected fun doTest(path: String) {
|
||||
setupMppProjectFromDirStructure(File(path))
|
||||
checkHighlightingInAllFiles()
|
||||
}
|
||||
}
|
||||
@@ -1,166 +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 com.intellij.openapi.roots.CompilerModuleExtension
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||
import org.jetbrains.kotlin.config.JvmTarget
|
||||
import org.jetbrains.kotlin.config.TargetPlatformKind
|
||||
import org.jetbrains.kotlin.idea.stubs.createFacet
|
||||
import org.jetbrains.kotlin.idea.test.PluginTestCaseBase
|
||||
import org.jetbrains.kotlin.test.TestJdkKind
|
||||
|
||||
class MultiModuleLineMarkerTest : AbstractMultiModuleHighlightingTest() {
|
||||
|
||||
override fun getTestDataPath() = PluginTestCaseBase.getTestDataPathBase() + "/multiModuleLineMarker/"
|
||||
|
||||
override val shouldCheckLineMarkers = true
|
||||
|
||||
override val shouldCheckResult = false
|
||||
|
||||
override fun doTestLineMarkers() = true
|
||||
|
||||
fun testFromActualAnnotation() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromActualPrimaryConstructor() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromActualSealedClass() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromActualSecondaryConstructor() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromActualTypeAlias() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromClassToAlias() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromClassToJavaAliasInTest() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromCommonToJvmHeader() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromCommonToJvmImpl() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromExpectedAnnotation() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromExpectedPrimaryConstructor() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromExpectedSealedClass() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromExpectedSecondaryConstructor() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testFromExpectedTypeAlias() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testHierarchyWithExpectClassCommonSide() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testHierarchyWithExpectClassCommonSideNonJavaIds() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testHierarchyWithExpectClassPlatformSide() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testKotlinTestAnnotations() {
|
||||
doMultiPlatformTest(TargetPlatformKind.JavaScript,
|
||||
configureModule = { module, _ ->
|
||||
ModuleRootModificationUtil.updateModel(module) {
|
||||
with(it.getModuleExtension(CompilerModuleExtension::class.java)!!) {
|
||||
inheritCompilerOutputPath(false)
|
||||
setCompilerOutputPathForTests("js_out")
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun testTopLevelFunWithKotlinTest() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
|
||||
fun testSuspendImplInPlatformModules() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6], TargetPlatformKind.JavaScript)
|
||||
}
|
||||
|
||||
fun testTransitive() {
|
||||
val commonModule = module("common", TestJdkKind.MOCK_JDK)
|
||||
commonModule.createFacet(TargetPlatformKind.Common, false)
|
||||
val jvmPlatform = TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]
|
||||
|
||||
val baseModule = module("jvm_base", TestJdkKind.MOCK_JDK)
|
||||
baseModule.createFacet(jvmPlatform, implementedModuleName = "common")
|
||||
baseModule.enableMultiPlatform()
|
||||
baseModule.addDependency(commonModule)
|
||||
|
||||
val userModule = module("jvm_user", TestJdkKind.MOCK_JDK)
|
||||
userModule.createFacet(jvmPlatform)
|
||||
userModule.enableMultiPlatform()
|
||||
userModule.addDependency(commonModule)
|
||||
userModule.addDependency(baseModule)
|
||||
|
||||
checkHighlightingInAllFiles()
|
||||
}
|
||||
|
||||
fun testTransitiveCommon() {
|
||||
val commonBaseModule = module("common_base", TestJdkKind.MOCK_JDK)
|
||||
commonBaseModule.createFacet(TargetPlatformKind.Common, false)
|
||||
|
||||
val commonUserModule = module("common_user", TestJdkKind.MOCK_JDK)
|
||||
commonUserModule.createFacet(TargetPlatformKind.Common, false)
|
||||
commonUserModule.enableMultiPlatform()
|
||||
commonUserModule.addDependency(commonBaseModule)
|
||||
|
||||
val jvmPlatform = TargetPlatformKind.Jvm[JvmTarget.JVM_1_6]
|
||||
val jvmModule = module("jvm", TestJdkKind.MOCK_JDK)
|
||||
jvmModule.createFacet(jvmPlatform, implementedModuleName = "common_user")
|
||||
jvmModule.enableMultiPlatform()
|
||||
jvmModule.addDependency(commonBaseModule)
|
||||
jvmModule.addDependency(commonUserModule)
|
||||
|
||||
checkHighlightingInAllFiles()
|
||||
}
|
||||
|
||||
fun testWithOverloads() {
|
||||
doMultiPlatformTest(TargetPlatformKind.Jvm[JvmTarget.JVM_1_6])
|
||||
}
|
||||
}
|
||||
Generated
+165
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright 2010-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/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.caches.resolve;
|
||||
|
||||
import com.intellij.testFramework.TestDataPath;
|
||||
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TargetBackend;
|
||||
import org.jetbrains.kotlin.test.TestMetadata;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||
@SuppressWarnings("all")
|
||||
@TestMetadata("idea/testData/multiModuleLineMarker")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class MultiModuleLineMarkerTestGenerated extends AbstractMultiModuleLineMarkerTest {
|
||||
public void testAllFilesPresentInMultiModuleLineMarker() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/multiModuleLineMarker"), Pattern.compile("^([^\\.]+)$"), TargetBackend.ANY, false);
|
||||
}
|
||||
|
||||
@TestMetadata("fromActualAnnotation")
|
||||
public void testFromActualAnnotation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromActualAnnotation/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromActualPrimaryConstructor")
|
||||
public void testFromActualPrimaryConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromActualPrimaryConstructor/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromActualSealedClass")
|
||||
public void testFromActualSealedClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromActualSealedClass/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromActualSecondaryConstructor")
|
||||
public void testFromActualSecondaryConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromActualSecondaryConstructor/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromActualTypeAlias")
|
||||
public void testFromActualTypeAlias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromActualTypeAlias/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromClassToAlias")
|
||||
public void testFromClassToAlias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromClassToAlias/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromClassToJavaAliasInTest")
|
||||
public void testFromClassToJavaAliasInTest() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromClassToJavaAliasInTest/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromCommonToJvmHeader")
|
||||
public void testFromCommonToJvmHeader() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromCommonToJvmHeader/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromCommonToJvmImpl")
|
||||
public void testFromCommonToJvmImpl() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromCommonToJvmImpl/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromExpectedAnnotation")
|
||||
public void testFromExpectedAnnotation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromExpectedAnnotation/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromExpectedPrimaryConstructor")
|
||||
public void testFromExpectedPrimaryConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromExpectedPrimaryConstructor/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromExpectedSealedClass")
|
||||
public void testFromExpectedSealedClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromExpectedSealedClass/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromExpectedSecondaryConstructor")
|
||||
public void testFromExpectedSecondaryConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromExpectedSecondaryConstructor/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("fromExpectedTypeAlias")
|
||||
public void testFromExpectedTypeAlias() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/fromExpectedTypeAlias/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("hierarchyWithExpectClassCommonSide")
|
||||
public void testHierarchyWithExpectClassCommonSide() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/hierarchyWithExpectClassCommonSide/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("hierarchyWithExpectClassCommonSideNonJavaIds")
|
||||
public void testHierarchyWithExpectClassCommonSideNonJavaIds() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/hierarchyWithExpectClassCommonSideNonJavaIds/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("hierarchyWithExpectClassPlatformSide")
|
||||
public void testHierarchyWithExpectClassPlatformSide() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/hierarchyWithExpectClassPlatformSide/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("kotlinTestAnnotations")
|
||||
public void testKotlinTestAnnotations() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/kotlinTestAnnotations/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("suspendImplInPlatformModules")
|
||||
public void testSuspendImplInPlatformModules() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/suspendImplInPlatformModules/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("topLevelFunWithKotlinTest")
|
||||
public void testTopLevelFunWithKotlinTest() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/topLevelFunWithKotlinTest/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("transitive")
|
||||
public void testTransitive() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/transitive/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("transitiveCommon")
|
||||
public void testTransitiveCommon() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/transitiveCommon/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("withOverloads")
|
||||
public void testWithOverloads() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/multiModuleLineMarker/withOverloads/");
|
||||
doTest(fileName);
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,8 @@ package org.jetbrains.kotlin.idea.multiplatform
|
||||
import com.intellij.openapi.command.WriteCommandAction
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.module.StdModuleTypes
|
||||
import com.intellij.openapi.roots.CompilerModuleExtension
|
||||
import com.intellij.openapi.roots.ModuleRootModificationUtil
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.testFramework.PlatformTestCase
|
||||
import junit.framework.TestCase
|
||||
@@ -61,10 +63,24 @@ private fun AbstractMultiModuleTest.createModuleWithRoots(
|
||||
val module = createModule(moduleId.ideaModuleName())
|
||||
for ((_, isTestRoot, moduleRoot) in infos) {
|
||||
addRoot(module, moduleRoot, isTestRoot)
|
||||
|
||||
if (moduleId.platform is TargetPlatformKind.JavaScript && isTestRoot) {
|
||||
setupJsTestOutput(module)
|
||||
}
|
||||
}
|
||||
return module
|
||||
}
|
||||
|
||||
// test line markers for JS do not work without additional setup
|
||||
private fun setupJsTestOutput(module: Module) {
|
||||
ModuleRootModificationUtil.updateModel(module) {
|
||||
with(it.getModuleExtension(CompilerModuleExtension::class.java)!!) {
|
||||
inheritCompilerOutputPath(false)
|
||||
setCompilerOutputPathForTests("js_out")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun AbstractMultiModuleTest.createModule(name: String): Module {
|
||||
val moduleDir = PlatformTestCase.createTempDir("")
|
||||
val module = createModule(moduleDir.toString() + "/" + name, StdModuleTypes.JAVA)
|
||||
|
||||
Reference in New Issue
Block a user