[SAM with receiver] Partially migrate tests to new infrastructure

Script tests still use old infrastructure, because there is no support
  for them in new framework
This commit is contained in:
Dmitriy Novozhilov
2022-06-22 13:57:21 +03:00
committed by teamcity
parent 04bf5bfe0b
commit 49c836e706
13 changed files with 66 additions and 37 deletions
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.kapt3.test.AbstractKotlinKaptContextTest
import org.jetbrains.kotlin.lombok.*
import org.jetbrains.kotlin.noarg.*
import org.jetbrains.kotlin.parcelize.test.runners.*
import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverScriptNewDefTest
import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverScriptTest
import org.jetbrains.kotlin.samWithReceiver.AbstractSamWithReceiverTest
import org.jetbrains.kotlin.test.TargetBackend
@@ -224,12 +225,13 @@ fun main(args: Array<String>) {
}
testGroup("plugins/sam-with-receiver/tests-gen", "plugins/sam-with-receiver/testData") {
testClass<AbstractSamWithReceiverTest> {
model("diagnostics")
}
testClass<AbstractSamWithReceiverScriptTest> {
model("script", extension = "kts")
}
testClass<AbstractSamWithReceiverScriptNewDefTest> {
model("script", extension = "kts")
}
}
testGroup(
@@ -449,5 +451,11 @@ fun main(args: Array<String>) {
model("diagnostics", excludedPattern = excludedFirTestdataPattern)
}
}
testGroup("plugins/sam-with-receiver/tests-gen", "plugins/sam-with-receiver/testData") {
testClass<AbstractSamWithReceiverTest> {
model("diagnostics", excludedPattern = excludedFirTestdataPattern)
}
}
}
}
@@ -5,20 +5,36 @@
package org.jetbrains.kotlin.samWithReceiver
import org.jetbrains.kotlin.ObsoleteTestInfrastructure
import org.jetbrains.kotlin.checkers.AbstractDiagnosticsTest
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import com.intellij.openapi.project.Project
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.extensions.StorageComponentContainerContributor
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives
import org.jetbrains.kotlin.test.directives.DiagnosticsDirectives.DIAGNOSTICS
import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.runners.AbstractDiagnosticTest
import org.jetbrains.kotlin.test.services.EnvironmentConfigurator
import org.jetbrains.kotlin.test.services.TestServices
@OptIn(ObsoleteTestInfrastructure::class)
abstract class AbstractSamWithReceiverTest : AbstractDiagnosticsTest() {
private companion object {
abstract class AbstractSamWithReceiverTest : AbstractDiagnosticTest() {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
builder.configurePlugin()
}
}
fun TestConfigurationBuilder.configurePlugin() {
useConfigurators(::SamWithReceiverEnvironmentConfigurator)
}
class SamWithReceiverEnvironmentConfigurator(testServices: TestServices) : EnvironmentConfigurator(testServices) {
companion object {
private val TEST_ANNOTATIONS = listOf("SamWithReceiver")
}
override fun setupEnvironment(environment: KotlinCoreEnvironment) {
override fun registerCompilerExtensions(project: Project, module: TestModule, configuration: CompilerConfiguration) {
StorageComponentContainerContributor.registerExtension(
environment.project,
project,
CliSamWithReceiverComponentContributor(TEST_ANNOTATIONS)
)
}
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
// FIR_IDENTICAL
// FILE: Sam.java
@SamWithReceiver
@@ -18,4 +18,4 @@ fun test() {
val a: String = <!NO_THIS!>this<!>
System.out.println(a)
}
}
}
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_ANONYMOUS_PARAMETER,-UNUSED_VARIABLE
// FIR_IDENTICAL
// FILE: Sam.java
@SamWithReceiver
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
// FIR_IDENTICAL
// FILE: Sam.java
@SamWithReceiver
@@ -25,4 +25,4 @@ fun test() {
val a: String = <!NO_THIS!>this<!>
System.out.println(a)
}
}
}
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
// FIR_IDENTICAL
// FILE: Sam.java
@SamWithReceiver
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
// FIR_IDENTICAL
// FILE: Sam.java
public interface Sam {
@@ -16,4 +16,4 @@ fun test() {
e.exec { a -> System.out.println(a) }
e.exec { System.out.println(<!NO_THIS!>this<!>) }
}
}
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_ANONYMOUS_PARAMETER,-UNUSED_VARIABLE
// FIR_IDENTICAL
// FILE: Sam.java
@SamWithReceiver
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_ANONYMOUS_PARAMETER,-UNUSED_VARIABLE
// FIR_IDENTICAL
// FILE: Sam.java
public interface Sam {
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
// FIR_IDENTICAL
// FILE: Sam.java
@SamWithReceiver
@@ -1,4 +1,4 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER,-UNUSED_VARIABLE
// FIR_IDENTICAL
// FILE: Sam.java
public interface Sam {
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.samWithReceiver;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
@@ -16,8 +17,8 @@ import java.util.regex.Pattern;
/** This class is generated by {@link org.jetbrains.kotlin.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/sam-with-receiver/sam-with-receiver-cli/testData/script")
@TestDataPath("/")
@TestMetadata("plugins/sam-with-receiver/testData/script")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class SamWithReceiverScriptNewDefTestGenerated extends AbstractSamWithReceiverScriptNewDefTest {
private void runTest(String testDataFilePath) throws Exception {
@@ -25,7 +26,7 @@ public class SamWithReceiverScriptNewDefTestGenerated extends AbstractSamWithRec
}
public void testAllFilesPresentInScript() throws Exception {
org.jetbrains.kotlin.test.util.KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/sam-with-receiver/sam-with-receiver-cli/testData/script"), Pattern.compile("^(.+)\\.kts$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/sam-with-receiver/testData/script"), Pattern.compile("^(.+)\\.kts$"), null, true);
}
@TestMetadata("samConversionSimple.kts")
@@ -6,69 +6,73 @@
package org.jetbrains.kotlin.samWithReceiver;
import com.intellij.testFramework.TestDataPath;
import org.jetbrains.kotlin.test.JUnit3RunnerWithInners;
import org.jetbrains.kotlin.test.KotlinTestUtils;
import org.jetbrains.kotlin.test.util.KtTestUtil;
import org.jetbrains.kotlin.test.TestMetadata;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
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 */
/** This class is generated by {@link GenerateNewCompilerTests.kt}. DO NOT MODIFY MANUALLY */
@SuppressWarnings("all")
@TestMetadata("plugins/sam-with-receiver/testData/diagnostics")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public class SamWithReceiverTestGenerated extends AbstractSamWithReceiverTest {
private void runTest(String testDataFilePath) throws Exception {
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
}
@Test
public void testAllFilesPresentInDiagnostics() throws Exception {
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/sam-with-receiver/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), null, true);
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("plugins/sam-with-receiver/testData/diagnostics"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@Test
@TestMetadata("noParameters.kt")
public void testNoParameters() throws Exception {
runTest("plugins/sam-with-receiver/testData/diagnostics/noParameters.kt");
}
@Test
@TestMetadata("noReturnType.kt")
public void testNoReturnType() throws Exception {
runTest("plugins/sam-with-receiver/testData/diagnostics/noReturnType.kt");
}
@Test
@TestMetadata("samConversionNoParameters.kt")
public void testSamConversionNoParameters() throws Exception {
runTest("plugins/sam-with-receiver/testData/diagnostics/samConversionNoParameters.kt");
}
@Test
@TestMetadata("samConversionSimple.kt")
public void testSamConversionSimple() throws Exception {
runTest("plugins/sam-with-receiver/testData/diagnostics/samConversionSimple.kt");
}
@Test
@TestMetadata("samConversionSimpleWithoutAnnotation.kt")
public void testSamConversionSimpleWithoutAnnotation() throws Exception {
runTest("plugins/sam-with-receiver/testData/diagnostics/samConversionSimpleWithoutAnnotation.kt");
}
@Test
@TestMetadata("samWithAnnotation.kt")
public void testSamWithAnnotation() throws Exception {
runTest("plugins/sam-with-receiver/testData/diagnostics/samWithAnnotation.kt");
}
@Test
@TestMetadata("samWithoutAnnotation.kt")
public void testSamWithoutAnnotation() throws Exception {
runTest("plugins/sam-with-receiver/testData/diagnostics/samWithoutAnnotation.kt");
}
@Test
@TestMetadata("singleParameter.kt")
public void testSingleParameter() throws Exception {
runTest("plugins/sam-with-receiver/testData/diagnostics/singleParameter.kt");
}
@Test
@TestMetadata("singleParameterWithoutAnnotation.kt")
public void testSingleParameterWithoutAnnotation() throws Exception {
runTest("plugins/sam-with-receiver/testData/diagnostics/singleParameterWithoutAnnotation.kt");