Configure AbstractInspectionTest with project descriptors
Previous implements produced flaky tests when non-js tests were executed after js.
This commit is contained in:
@@ -62,7 +62,8 @@ public class ConfigLibraryUtil {
|
|||||||
|
|
||||||
public static void configureKotlinJsRuntimeAndSdk(Module module, Sdk sdk) {
|
public static void configureKotlinJsRuntimeAndSdk(Module module, Sdk sdk) {
|
||||||
configureSdk(module, sdk);
|
configureSdk(module, sdk);
|
||||||
configureKotlinJsRuntime(module);
|
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_JS_STDLIB_NAME,
|
||||||
|
PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath()), module);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureKotlinRuntime(Module module) {
|
public static void configureKotlinRuntime(Module module) {
|
||||||
@@ -72,11 +73,6 @@ public class ConfigLibraryUtil {
|
|||||||
module);
|
module);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void configureKotlinJsRuntime(Module module) {
|
|
||||||
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_JS_STDLIB_NAME,
|
|
||||||
PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath()), module);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void unConfigureKotlinRuntime(Module module) {
|
public static void unConfigureKotlinRuntime(Module module) {
|
||||||
removeLibrary(module, DEFAULT_JAVA_RUNTIME_LIB_NAME);
|
removeLibrary(module, DEFAULT_JAVA_RUNTIME_LIB_NAME);
|
||||||
removeLibrary(module, DEFAULT_KOTLIN_TEST_LIB_NAME);
|
removeLibrary(module, DEFAULT_KOTLIN_TEST_LIB_NAME);
|
||||||
|
|||||||
+1
@@ -1 +1,2 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnsafeCastFromDynamicInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnsafeCastFromDynamicInspection
|
||||||
|
// JS
|
||||||
@@ -1 +1,2 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.KotlinUnusedImportInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.KotlinUnusedImportInspection
|
||||||
|
// RUNTIME_WITH_FULL_JDK
|
||||||
@@ -1 +1,2 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
|
||||||
|
// RUNTIME_WITH_FULL_JDK
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|||||||
+1
@@ -1 +1,2 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisInspection
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|||||||
+1
@@ -1 +1,2 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessInspection
|
||||||
|
// WITH_RUNTIME
|
||||||
+1
@@ -1 +1,2 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.DestructureInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.DestructureInspection
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.DestructureInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.DestructureInspection
|
||||||
|
// WITH_RUNTIME
|
||||||
|
|||||||
+1
@@ -1 +1,2 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsInspection
|
||||||
|
// WITH_RUNTIME
|
||||||
@@ -35,8 +35,6 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase()
|
|||||||
val ENTRY_POINT_ANNOTATION = "test.anno.EntryPoint"
|
val ENTRY_POINT_ANNOTATION = "test.anno.EntryPoint"
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinLightProjectDescriptor.INSTANCE
|
|
||||||
|
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
super.setUp()
|
super.setUp()
|
||||||
EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.add(ENTRY_POINT_ANNOTATION)
|
EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.add(ENTRY_POINT_ANNOTATION)
|
||||||
@@ -90,27 +88,7 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase()
|
|||||||
}
|
}
|
||||||
}.toList()
|
}.toList()
|
||||||
|
|
||||||
val isJs = srcDir.endsWith("js")
|
|
||||||
|
|
||||||
val isWithRuntime = psiFiles.any { InTextDirectivesUtils.findStringWithPrefixes(it.text, "// WITH_RUNTIME") != null }
|
|
||||||
val fullJdk = psiFiles.any { InTextDirectivesUtils.findStringWithPrefixes(it.text, "// FULL_JDK") != null }
|
|
||||||
|
|
||||||
if (isJs) {
|
|
||||||
assertFalse(isWithRuntime)
|
|
||||||
assertFalse(fullJdk)
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (isJs) {
|
|
||||||
ConfigLibraryUtil.configureKotlinJsRuntime(myFixture.module)
|
|
||||||
}
|
|
||||||
if (isWithRuntime) {
|
|
||||||
ConfigLibraryUtil.configureKotlinRuntimeAndSdk(
|
|
||||||
myFixture.module,
|
|
||||||
if (fullJdk) PluginTestCaseBase.fullJdk() else PluginTestCaseBase.mockJdk()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fixtureClasses.forEach { TestFixtureExtension.loadFixture(it, myFixture.module) }
|
fixtureClasses.forEach { TestFixtureExtension.loadFixture(it, myFixture.module) }
|
||||||
|
|
||||||
configExtra(psiFiles, options)
|
configExtra(psiFiles, options)
|
||||||
@@ -137,13 +115,6 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase()
|
|||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
fixtureClasses.forEach { TestFixtureExtension.unloadFixture(it) }
|
fixtureClasses.forEach { TestFixtureExtension.unloadFixture(it) }
|
||||||
|
|
||||||
if (isWithRuntime) {
|
|
||||||
ConfigLibraryUtil.unConfigureKotlinRuntimeAndSdk(myFixture.module, IdeaTestUtil.getMockJdk17())
|
|
||||||
}
|
|
||||||
if (isJs) {
|
|
||||||
ConfigLibraryUtil.unConfigureKotlinJsRuntimeAndSdk(myFixture.module, IdeaTestUtil.getMockJdk17())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -191,9 +191,9 @@ public class InspectionTestGenerated extends AbstractInspectionTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("dynamic/js/inspectionData/inspections.test")
|
@TestMetadata("dynamic/inspectionData/inspections.test")
|
||||||
public void testDynamic_js_inspectionData_Inspections_test() throws Exception {
|
public void testDynamic_inspectionData_Inspections_test() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspections/dynamic/js/inspectionData/inspections.test");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspections/dynamic/inspectionData/inspections.test");
|
||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -1,3 +1,4 @@
|
|||||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.spring.inspections.SpringKotlinAutowiringInspection
|
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.spring.inspections.SpringKotlinAutowiringInspection
|
||||||
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
|
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
|
||||||
// CONFIGURE_SPRING_FILE_SET
|
// CONFIGURE_SPRING_FILE_SET
|
||||||
|
// RUNTIME_WITH_FULL_JDK
|
||||||
Reference in New Issue
Block a user