[jvm] Properly enable K2 mode for K2 tests

Also ignores any failing tests

GitOrigin-RevId: db34ca3d4690285cd7ed4186c76f31e81e7fab46
This commit is contained in:
Bart van Helvert
2024-09-11 18:08:14 +02:00
committed by intellij-monorepo-bot
parent 689dd2e194
commit c8c478bdbc
63 changed files with 296 additions and 9 deletions

View File

@@ -4,6 +4,7 @@ package com.intellij.codeInspection.tests.kotlin;
import com.intellij.codeInspection.blockingCallsDetection.BlockingMethodInNonBlockingContextInspection;
import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProviderKt;
import static com.intellij.codeInspection.blockingCallsDetection.BlockingMethodInNonBlockingContextInspection.DEFAULT_BLOCKING_ANNOTATIONS;
import static com.intellij.codeInspection.blockingCallsDetection.BlockingMethodInNonBlockingContextInspection.DEFAULT_NONBLOCKING_ANNOTATIONS;
@@ -11,7 +12,7 @@ import static com.intellij.codeInspection.blockingCallsDetection.BlockingMethodI
public abstract class KotlinBlockingCallDetectionTest extends JavaCodeInsightFixtureTestCase implements ExpectedPluginModeProvider {
@Override
protected void setUp() throws Exception {
super.setUp();
ExpectedPluginModeProviderKt.setUpWithKotlinPlugin(this, getTestRootDisposable(), super::setUp);
BlockingMethodInNonBlockingContextInspection myInspection = new BlockingMethodInNonBlockingContextInspection();
myInspection.myBlockingAnnotations = DEFAULT_BLOCKING_ANNOTATIONS;
myInspection.myNonBlockingAnnotations = DEFAULT_NONBLOCKING_ANNOTATIONS;

View File

@@ -4,8 +4,14 @@ import com.intellij.jvm.analysis.internal.testFramework.CallMatcherTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import com.siyeh.ig.callMatcher.CallMatcher
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinCallMatcherTest : CallMatcherTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun testInstanceMethodCall() {
checkMatchCall(JvmLanguage.KOTLIN, CallMatcher.instanceCall("Foo", "bar").parameterCount(0), """
class Foo { fun bar() { } }

View File

@@ -2,8 +2,13 @@ package com.intellij.codeInspection.tests.kotlin
import com.intellij.jvm.analysis.internal.testFramework.DependencyInspectionTestBase
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinDependencyInspectionTest : DependencyInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test illegal imported dependency Java API`() = dependencyViolationTest(javaFooFile, "ImportClientJava.kt", """
package pkg.client

View File

@@ -6,11 +6,16 @@ import com.intellij.jvm.analysis.KotlinJvmAnalysisTestUtil
import com.intellij.jvm.analysis.testFramework.JvmInspectionTestBase
import com.intellij.testFramework.TestDataPath
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
private const val inspectionPath = "/codeInspection/emptyMethod"
@TestDataPath("\$CONTENT_ROOT/testData$inspectionPath")
abstract class KotlinEmptyMethodInspectionTest : JvmInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override var inspection = EmptyMethodInspection()
override fun getBasePath() = KotlinJvmAnalysisTestUtil.TEST_DATA_PROJECT_RELATIVE_BASE_PATH + inspectionPath

View File

@@ -4,8 +4,13 @@ import com.intellij.jvm.analysis.internal.testFramework.JavaApiUsageInspectionTe
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import com.intellij.pom.java.LanguageLevel
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinJavaApiUsageInspectionTest : JavaApiUsageInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test constructor`() {
myFixture.setLanguageLevel(LanguageLevel.JDK_1_4)
myFixture.testHighlighting(JvmLanguage.KOTLIN, """

View File

@@ -4,8 +4,13 @@ import com.intellij.codeInspection.deprecation.MarkedForRemovalInspection
import com.intellij.jvm.analysis.testFramework.JvmInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinMarkedForRemovalInspectionTest : JvmInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test highlighted as deprecated for removal`() {
myFixture.addClass("""
package test;

View File

@@ -4,8 +4,13 @@ import com.intellij.jvm.analysis.internal.testFramework.MigrationTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import com.intellij.refactoring.migration.MigrationMapEntry
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinMigrationTest : MigrationTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test package`() {
migrationTest(JvmLanguage.KOTLIN, before = """
package p1

View File

@@ -4,11 +4,16 @@ import com.intellij.jvm.analysis.KotlinJvmAnalysisTestUtil
import com.intellij.jvm.analysis.internal.testFramework.MissingDeprecatedAnnotationOnScheduledForRemovalApiInspectionTestBase
import com.intellij.testFramework.TestDataPath
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
private const val inspectionPath = "/codeInspection/missingDeprecatedAnnotationOnScheduledForRemovalApi"
@TestDataPath("\$CONTENT_ROOT/testData$inspectionPath")
abstract class KotlinMissingDeprecatedAnnotationOnScheduledForRemovalApiInspectionTest : MissingDeprecatedAnnotationOnScheduledForRemovalApiInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override fun getBasePath() = KotlinJvmAnalysisTestUtil.TEST_DATA_PROJECT_RELATIVE_BASE_PATH + inspectionPath
fun `test missing @Deprecated on @ScheduledForRemoval APIs`() {

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin
import com.intellij.jvm.analysis.internal.testFramework.MustAlreadyBeRemovedApiInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinMustAlreadyBeRemovedApiInspectionTest : MustAlreadyBeRemovedApiInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test APIs must have been removed`() {
inspection.currentVersion = "3.0"
myFixture.testHighlighting(JvmLanguage.KOTLIN, """

View File

@@ -11,11 +11,16 @@ import com.intellij.testFramework.TestDataPath
import com.intellij.util.PathUtil
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
@TestDataPath("/testData/codeInspection/nonExtendableApiUsage")
abstract class KotlinNonExtendableApiUsageInspectionTest : JvmInspectionTestBase(), ExpectedPluginModeProvider {
override val inspection = NonExtendableApiUsageInspection()
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override fun getProjectDescriptor() = object : ProjectDescriptor(LanguageLevel.HIGHEST) {
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) {
super.configureModule(module, model, contentEntry)

View File

@@ -10,6 +10,7 @@ import com.intellij.util.PathUtil;
import kotlin.KotlinVersion;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProviderKt;
import org.jetbrains.uast.ULiteralExpression;
import org.junit.Assume;
@@ -23,7 +24,7 @@ import static com.intellij.jvm.analysis.internal.testFramework.JvmAnalysisTestsU
public abstract class KotlinNonNlsUastUtilTest extends JavaCodeInsightFixtureTestCase implements ExpectedPluginModeProvider {
@Override
protected void setUp() throws Exception {
super.setUp();
ExpectedPluginModeProviderKt.setUpWithKotlinPlugin(this, getTestRootDisposable(), super::setUp);
Assume.assumeTrue(KotlinVersion.CURRENT.isAtLeast(1, 2, 60));
}

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin
import com.intellij.jvm.analysis.internal.testFramework.ObsoleteApiUsageInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinObsoleteApiUsageInspectionTest : ObsoleteApiUsageInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test direct usage`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
class B {

View File

@@ -12,11 +12,16 @@ import com.intellij.testFramework.TestDataPath
import com.intellij.util.PathUtil
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
@TestDataPath("/testData/codeInspection/overrideOnly")
abstract class KotlinOverrideOnlyInspectionTest : JvmInspectionTestBase(), ExpectedPluginModeProvider {
override val inspection: InspectionProfileEntry = OverrideOnlyInspection()
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override fun getProjectDescriptor() = object : ProjectDescriptor(LanguageLevel.HIGHEST) {
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) {
super.configureModule(module, model, contentEntry)

View File

@@ -11,9 +11,14 @@ import com.intellij.openapi.application.PathManager
import com.intellij.testFramework.InspectionTestUtil
import com.intellij.testFramework.createGlobalContextForTool
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
import java.io.File
abstract class KotlinRedundantRequiresStatementTest : LightJava9ModulesCodeInsightFixtureTestCase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun testStdlib() {
val mainText = """
package org.example.main

View File

@@ -2,8 +2,13 @@ package com.intellij.codeInspection.tests.kotlin
import com.intellij.jvm.analysis.internal.testFramework.SameParameterValueInspectionTestBase
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinSameParameterValueGlobalInspectionTest : SameParameterValueInspectionTestBase(false), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun testEntryPoint() {
doHighlightTest(runDeadCodeFirst = true)
}

View File

@@ -2,8 +2,13 @@ package com.intellij.codeInspection.tests.kotlin
import com.intellij.jvm.analysis.internal.testFramework.SameParameterValueInspectionTestBase
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinSameParameterValueLocalInspectionTest : SameParameterValueInspectionTestBase(true), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun testEntryPoint() {
doHighlightTest(runDeadCodeFirst = true)
}

View File

@@ -4,10 +4,16 @@ import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.sameReturnValue.SameReturnValueInspection;
import com.intellij.testFramework.JavaInspectionTestCase;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProviderKt;
public abstract class KotlinSameReturnValueGlobalInspectionTest extends JavaInspectionTestCase implements ExpectedPluginModeProvider {
private final SameReturnValueInspection myGlobalTool = new SameReturnValueInspection();
@Override
protected void setUp() throws Exception {
ExpectedPluginModeProviderKt.setUpWithKotlinPlugin(this, getTestRootDisposable(), super::setUp);
}
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath() + "/inspection/jvm";

View File

@@ -4,6 +4,7 @@ import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.sameReturnValue.SameReturnValueInspection;
import com.intellij.testFramework.fixtures.LightJavaCodeInsightFixtureTestCase;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProviderKt;
public abstract class KotlinSameReturnValueLocalInspectionTest extends LightJavaCodeInsightFixtureTestCase implements ExpectedPluginModeProvider {
@@ -14,7 +15,7 @@ public abstract class KotlinSameReturnValueLocalInspectionTest extends LightJava
@Override
protected void setUp() throws Exception {
super.setUp();
ExpectedPluginModeProviderKt.setUpWithKotlinPlugin(this, getTestRootDisposable(), super::setUp);
myFixture.enableInspections(new SameReturnValueInspection().getSharedLocalInspectionTool());
}

View File

@@ -5,8 +5,13 @@ import com.intellij.jvm.analysis.testFramework.JvmLanguage
import com.intellij.pom.java.LanguageLevel
import com.intellij.testFramework.IdeaTestUtil
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinSerializableHasSerialVersionUidFieldInspectionTest : SerializableHasSerialVersionUidFieldInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test highlighting`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
import java.io.Serializable

View File

@@ -3,8 +3,12 @@ package com.intellij.codeInspection.tests.kotlin
import com.intellij.jvm.analysis.internal.testFramework.SuppressionAnnotationInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinSuppressionAnnotationInspectionTest : SuppressionAnnotationInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test highlighting`() {
inspection.myAllowedSuppressions.add("FreeSpeech")

View File

@@ -4,9 +4,14 @@ import com.intellij.jvm.analysis.KotlinJvmAnalysisTestUtil
import com.intellij.testFramework.TestDataPath
import com.siyeh.ig.dependency.SuspiciousPackagePrivateAccessInspectionTestCase
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
@TestDataPath("\$CONTENT_ROOT/testData/codeInspection/suspiciousPackagePrivateAccess")
abstract class KotlinSuspiciousPackagePrivateAccessInspectionTest : SuspiciousPackagePrivateAccessInspectionTestCase("kt"), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun testAccessingPackagePrivateMembers() {
doTestWithDependency()
}

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin
import com.intellij.jvm.analysis.internal.testFramework.SystemGetPropertyInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinSystemGetPropertyInspectionTest : SystemGetPropertyInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test highlighting`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
fun foo() {

View File

@@ -4,11 +4,16 @@ import com.intellij.jvm.analysis.KotlinJvmAnalysisTestUtil
import com.intellij.jvm.analysis.internal.testFramework.ThreadRunInspectionTestBase
import com.intellij.testFramework.TestDataPath
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
private const val inspectionPath = "/codeInspection/threadrun"
@TestDataPath("\$CONTENT_ROOT/testData$inspectionPath")
abstract class KotlinThreadRunInspectionTest : ThreadRunInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override fun getBasePath() = KotlinJvmAnalysisTestUtil.TEST_DATA_PROJECT_RELATIVE_BASE_PATH + inspectionPath
fun `test highlighting`() {

View File

@@ -4,8 +4,13 @@ package com.intellij.codeInspection.tests.kotlin
import com.intellij.jvm.analysis.internal.testFramework.UnstableApiUsageInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinUnstableApiUsageInspectionTest : UnstableApiUsageInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test kotlin unstable api usages`() {
inspection.myIgnoreInsideImports = false
myFixture.testHighlighting(JvmLanguage.KOTLIN, """

View File

@@ -9,6 +9,7 @@ import com.intellij.testFramework.fixtures.JavaCodeInsightFixtureTestCase
import com.intellij.util.PathUtil
import org.jetbrains.annotations.ApiStatus
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
import java.io.File
@TestDataPath("\$CONTENT_ROOT/testData/codeInspection/unstableTypeUsedInSignature")
@@ -20,12 +21,14 @@ abstract class KotlinUnstableTypeUsedInSignatureTest : JavaCodeInsightFixtureTes
override fun setUp() {
super.setUp()
val inspection = UnstableTypeUsedInSignatureInspection()
inspection.unstableApiAnnotations.clear()
inspection.unstableApiAnnotations.add(ApiStatus.Experimental::class.java.canonicalName)
myFixture.enableInspections(inspection)
configureAnnotatedFiles()
setUpWithKotlinPlugin(testRootDisposable) {
super.setUp()
val inspection = UnstableTypeUsedInSignatureInspection()
inspection.unstableApiAnnotations.clear()
inspection.unstableApiAnnotations.add(ApiStatus.Experimental::class.java.canonicalName)
myFixture.enableInspections(inspection)
configureAnnotatedFiles()
}
}
private fun configureAnnotatedFiles() {

View File

@@ -4,8 +4,14 @@ import com.intellij.java.codeInspection.AbstractUnusedDeclarationTest;
import com.intellij.java.codeInspection.UnusedDeclarationInspectionTest;
import com.intellij.openapi.application.ex.PathManagerEx;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProviderKt;
public abstract class KotlinUnusedDeclarationTest extends AbstractUnusedDeclarationTest implements ExpectedPluginModeProvider {
@Override
protected void setUp() throws Exception {
ExpectedPluginModeProviderKt.setUpWithKotlinPlugin(this, getTestRootDisposable(), super::setUp);
}
@Override
protected String getTestDataPath() {
return PathManagerEx.getTestDataPath(UnusedDeclarationInspectionTest.class) + "/inspection/jvm";

View File

@@ -4,10 +4,16 @@ import com.intellij.JavaTestUtil;
import com.intellij.codeInspection.unusedReturnValue.UnusedReturnValue;
import com.intellij.testFramework.JavaInspectionTestCase;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider;
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProviderKt;
public abstract class KotlinUnusedReturnValueInspectionKtTest extends JavaInspectionTestCase implements ExpectedPluginModeProvider {
private final UnusedReturnValue myGlobalTool = new UnusedReturnValue();
@Override
protected void setUp() throws Exception {
ExpectedPluginModeProviderKt.setUpWithKotlinPlugin(this, getTestRootDisposable(), super::setUp);
}
@Override
protected String getTestDataPath() {
return JavaTestUtil.getJavaTestDataPath() + "/inspection/jvm";

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin.deadCode
import com.intellij.jvm.analysis.internal.testFramework.deadCode.AssertJImplicitUsageProviderTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinAssertJImplicitUsageProviderTest : AssertJImplicitUsageProviderTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test inject soft assertion implicit usage provider`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
@org.junit.jupiter.api.extension.ExtendWith(org.assertj.core.api.junit.jupiter.SoftAssertionsExtension::class)

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin.deadCode
import com.intellij.jvm.analysis.internal.testFramework.deadCode.EasyMockImplicitUsageProviderTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinEasyMockImplicitUsageProviderTest : EasyMockImplicitUsageProviderTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test implicit usage for mocked field`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
class MyEasyMockTest {

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin.deadCode
import com.intellij.jvm.analysis.internal.testFramework.deadCode.MockitoImplicitUsageProviderTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinMockitoImplicitUsageProviderTest : MockitoImplicitUsageProviderTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test implicit usage for mocked field`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
class MyMockitoTest {

View File

@@ -4,8 +4,13 @@ import com.intellij.analysis.JvmAnalysisBundle
import com.intellij.jvm.analysis.internal.testFramework.logging.LoggingConditionDisagreesWithLogLevelStatementInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinLoggingConditionDisagreesWithLogLevelStatementInspectionTest : LoggingConditionDisagreesWithLogLevelStatementInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test slf4j`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
import org.slf4j.LoggerFactory

View File

@@ -4,8 +4,13 @@ import com.intellij.analysis.JvmAnalysisBundle
import com.intellij.jvm.analysis.internal.testFramework.logging.LoggingGuardedByConditionInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinLoggingGuardedByConditionInspectionTest : LoggingGuardedByConditionInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test slf4j`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
import org.slf4j.Logger

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin.logging
import com.intellij.jvm.analysis.internal.testFramework.logging.LoggingPlaceholderCountMatchesArgumentCountInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionLog4J2Test : LoggingPlaceholderCountMatchesArgumentCountInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test log4j2 with text variables`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
import org.apache.logging.log4j.LogManager

View File

@@ -4,8 +4,13 @@ import com.intellij.codeInspection.logging.LoggingPlaceholderCountMatchesArgumen
import com.intellij.jvm.analysis.internal.testFramework.logging.LoggingPlaceholderCountMatchesArgumentCountInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionPlaceholderNumberTest : LoggingPlaceholderCountMatchesArgumentCountInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test many variables`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
import org.slf4j.LoggerFactory

View File

@@ -4,8 +4,13 @@ import com.intellij.codeInspection.logging.LoggingPlaceholderCountMatchesArgumen
import com.intellij.jvm.analysis.internal.testFramework.logging.LoggingPlaceholderCountMatchesArgumentCountInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinLoggingPlaceholderCountMatchesArgumentCountInspectionSlf4JTest : LoggingPlaceholderCountMatchesArgumentCountInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test slf4j disable slf4jToLog4J2Type`() {
inspection.slf4jToLog4J2Type = LoggingPlaceholderCountMatchesArgumentCountInspection.Slf4jToLog4J2Type.NO
myFixture.testHighlighting(JvmLanguage.KOTLIN, """

View File

@@ -3,8 +3,12 @@ package com.intellij.codeInspection.tests.kotlin.logging
import com.intellij.jvm.analysis.internal.testFramework.logging.LoggingSimilarMessageInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinLoggingSimilarMessageInspectionTest : LoggingSimilarMessageInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test equals log4j2`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """

View File

@@ -4,8 +4,13 @@ import com.intellij.analysis.JvmAnalysisBundle
import com.intellij.jvm.analysis.internal.testFramework.logging.LoggingStatementNotGuardedByLogConditionInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinLoggingStatementNotGuardedByLogConditionInspectionTest : LoggingStatementNotGuardedByLogConditionInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test slf4j`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
import org.slf4j.Logger

View File

@@ -6,11 +6,16 @@ import com.intellij.jvm.analysis.KotlinJvmAnalysisTestUtil
import com.intellij.jvm.analysis.internal.testFramework.logging.LoggingStringTemplateAsArgumentInspectionTestBase
import com.intellij.testFramework.TestDataPath
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
private const val INSPECTION_PATH = "/codeInspection/logging/stringTemplateAsArgument"
@TestDataPath("\$CONTENT_ROOT/testData$INSPECTION_PATH")
abstract class KotlinLoggingStringTemplateAsArgumentInspectionTest : LoggingStringTemplateAsArgumentInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override val inspection: LoggingStringTemplateAsArgumentInspection = LoggingStringTemplateAsArgumentInspection().apply {
myLimitLevelType = LoggingUtil.LimitLevelType.ALL
}

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin.performance
import com.intellij.jvm.analysis.internal.testFramework.performance.UrlHashCodeInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinUrlHashCodeInspectionTest : UrlHashCodeInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test url hashcode call`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
import java.net.URL

View File

@@ -6,11 +6,16 @@ import com.intellij.jvm.analysis.internal.testFramework.sourceToSink.SourceToSin
import com.intellij.testFramework.TestDataPath
import org.jetbrains.annotations.Nls
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
private const val inspectionPath = "/codeInspection/sourceToSinkFlow/markAsSafeFix"
@TestDataPath("\$CONTENT_ROOT/testData$inspectionPath")
abstract class KotlinMarkAsSafeFixSourceToSinkFlowInspectionTest : SourceToSinkFlowInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override fun getBasePath() = KotlinJvmAnalysisTestUtil.TEST_DATA_PROJECT_RELATIVE_BASE_PATH + inspectionPath
fun `test common cases with checkFramework`() {

View File

@@ -5,11 +5,16 @@ import com.intellij.jvm.analysis.KotlinJvmAnalysisTestUtil
import com.intellij.jvm.analysis.internal.testFramework.sourceToSink.SourceToSinkFlowInspectionTestBase
import com.intellij.testFramework.TestDataPath
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
private const val INSPECTION_PATH = "/codeInspection/sourceToSinkFlow"
@TestDataPath("\$CONTENT_ROOT/testData$INSPECTION_PATH")
abstract class KotlinSourceToSinkFlowInspectionTest : SourceToSinkFlowInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override fun getBasePath() = KotlinJvmAnalysisTestUtil.TEST_DATA_PROJECT_RELATIVE_BASE_PATH + INSPECTION_PATH
fun testSimple() {

View File

@@ -10,9 +10,14 @@ import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.testFramework.PsiTestUtil
import com.intellij.util.PathUtil
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
import java.io.File
abstract class KotlinAssertEqualsBetweenInconvertibleTypesInspectionTest : AssertEqualsBetweenInconvertibleTypesInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override fun getProjectDescriptor(): LightProjectDescriptor = object : AssertJProjectDescriptor(LanguageLevel.HIGHEST) {
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) {
super.configureModule(module, model, contentEntry)

View File

@@ -10,9 +10,14 @@ import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.testFramework.PsiTestUtil
import com.intellij.util.PathUtil
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
import java.io.File
abstract class KotlinTestCaseWithConstructorInspectionTest : TestCaseWithConstructorInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override fun getProjectDescriptor(): LightProjectDescriptor = object : JUnitProjectDescriptor(LanguageLevel.HIGHEST) {
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) {
super.configureModule(module, model, contentEntry)

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin.test
import com.intellij.jvm.analysis.internal.testFramework.test.TestCaseWithoutTestsInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinTestCaseWithoutTestsInspectionTest : TestCaseWithoutTestsInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test case without test methods`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
class <warning descr="Test class 'TestCaseWithNoTestMethods' has no tests">TestCaseWithNoTestMethods</warning> : junit.framework.TestCase() {

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin.test
import com.intellij.jvm.analysis.internal.testFramework.test.TestFailedLineInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinTestFailedLineInspectionTest : TestFailedLineInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test non qualified call`() {
doTest(
lang = JvmLanguage.KOTLIN,

View File

@@ -11,9 +11,14 @@ import com.intellij.testFramework.LightProjectDescriptor
import com.intellij.testFramework.PsiTestUtil
import com.intellij.util.PathUtil
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
import java.io.File
abstract class KotlinTestMethodWithoutAssertionInspectionTest : TestMethodWithoutAssertionInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
override fun getProjectDescriptor(): LightProjectDescriptor = object : TestFrameworkDescriptor(LanguageLevel.HIGHEST) {
override fun configureModule(module: Module, model: ModifiableRootModel, contentEntry: ContentEntry) {
super.configureModule(module, model, contentEntry)

View File

@@ -3,8 +3,13 @@ package com.intellij.codeInspection.tests.kotlin.test
import com.intellij.jvm.analysis.internal.testFramework.test.TestOnlyInspectionTestBase
import com.intellij.jvm.analysis.testFramework.JvmLanguage
import org.jetbrains.kotlin.idea.test.ExpectedPluginModeProvider
import org.jetbrains.kotlin.idea.test.setUpWithKotlinPlugin
abstract class KotlinTestOnlyInspectionTest : TestOnlyInspectionTestBase(), ExpectedPluginModeProvider {
override fun setUp() {
setUpWithKotlinPlugin(testRootDisposable) { super.setUp() }
}
fun `test @TestOnly on use-site targets`() {
myFixture.testHighlighting(JvmLanguage.KOTLIN, """
package test