Configure AbstractInspectionTest with project descriptors

Previous implements produced flaky tests when non-js tests were
executed after js.
This commit is contained in:
Nikolay Krasko
2017-06-27 16:44:02 +03:00
parent be28c4a48f
commit df393e18fe
15 changed files with 16 additions and 39 deletions
@@ -62,7 +62,8 @@ public class ConfigLibraryUtil {
public static void configureKotlinJsRuntimeAndSdk(Module module, Sdk sdk) {
configureSdk(module, sdk);
configureKotlinJsRuntime(module);
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_JS_STDLIB_NAME,
PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath()), module);
}
public static void configureKotlinRuntime(Module module) {
@@ -72,11 +73,6 @@ public class ConfigLibraryUtil {
module);
}
public static void configureKotlinJsRuntime(Module module) {
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_JS_STDLIB_NAME,
PathUtil.getKotlinPathsForDistDirectory().getJsStdLibJarPath()), module);
}
public static void unConfigureKotlinRuntime(Module module) {
removeLibrary(module, DEFAULT_JAVA_RUNTIME_LIB_NAME);
removeLibrary(module, DEFAULT_KOTLIN_TEST_LIB_NAME);
@@ -1 +1,2 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnsafeCastFromDynamicInspection
// JS
@@ -1 +1,2 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.KotlinUnusedImportInspection
// RUNTIME_WITH_FULL_JDK
@@ -1 +1,2 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
// RUNTIME_WITH_FULL_JDK
@@ -1 +1,2 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
// WITH_RUNTIME
@@ -1 +1,2 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisInspection
// WITH_RUNTIME
@@ -1 +1,2 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessInspection
// WITH_RUNTIME
@@ -1 +1,2 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.DestructureInspection
// WITH_RUNTIME
@@ -1 +1,2 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.DestructureInspection
// WITH_RUNTIME
@@ -1 +1,2 @@
// 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"
}
override fun getProjectDescriptor(): LightProjectDescriptor = KotlinLightProjectDescriptor.INSTANCE
override fun setUp() {
super.setUp()
EntryPointsManagerBase.getInstance(project).ADDITIONAL_ANNOTATIONS.add(ENTRY_POINT_ANNOTATION)
@@ -90,27 +88,7 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase()
}
}.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 {
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) }
configExtra(psiFiles, options)
@@ -137,13 +115,6 @@ abstract class AbstractInspectionTest : KotlinLightCodeInsightFixtureTestCase()
}
finally {
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);
}
@TestMetadata("dynamic/js/inspectionData/inspections.test")
public void testDynamic_js_inspectionData_Inspections_test() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspections/dynamic/js/inspectionData/inspections.test");
@TestMetadata("dynamic/inspectionData/inspections.test")
public void testDynamic_inspectionData_Inspections_test() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspections/dynamic/inspectionData/inspections.test");
doTest(fileName);
}
@@ -1,3 +1,4 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.spring.inspections.SpringKotlinAutowiringInspection
// FIXTURE_CLASS: org.jetbrains.kotlin.idea.spring.tests.SpringTestFixtureExtension
// CONFIGURE_SPRING_FILE_SET
// CONFIGURE_SPRING_FILE_SET
// RUNTIME_WITH_FULL_JDK