[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:
committed by
teamcity
parent
04bf5bfe0b
commit
49c836e706
+24
-8
@@ -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)
|
||||
)
|
||||
}
|
||||
|
||||
-35
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2022 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.
|
||||
*/
|
||||
|
||||
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.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("plugins/sam-with-receiver/sam-with-receiver-cli/testData/script")
|
||||
@TestDataPath("/")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public class SamWithReceiverScriptNewDefTestGenerated extends AbstractSamWithReceiverScriptNewDefTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, this, testDataFilePath);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@TestMetadata("samConversionSimple.kts")
|
||||
public void testSamConversionSimple() throws Exception {
|
||||
runTest("plugins/sam-with-receiver/testData/script/samConversionSimple.kts");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user