diff --git a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt index 4d963dbaaea..78c90299eca 100644 --- a/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt +++ b/compiler/tests-for-compiler-generator/tests/org/jetbrains/kotlin/test/generators/GenerateJUnit3CompilerTests.kt @@ -108,6 +108,10 @@ fun generateJUnit3CompilerTests(args: Array) { model("codegen/customScript", pattern = "^(.*)$") } + testClass { + model("codegen/customScript", pattern = "^(.*)$") + } + testClass { model("ir/irJsText", pattern = "^(.+)\\.kt(s)?\$") } diff --git a/compiler/tests-gen/org/jetbrains/kotlin/codegen/IrCustomScriptCodegenTestGenerated.java b/compiler/tests-gen/org/jetbrains/kotlin/codegen/IrCustomScriptCodegenTestGenerated.java new file mode 100644 index 00000000000..557263046c9 --- /dev/null +++ b/compiler/tests-gen/org/jetbrains/kotlin/codegen/IrCustomScriptCodegenTestGenerated.java @@ -0,0 +1,56 @@ +/* + * 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.codegen; + +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 java.io.File; +import java.util.regex.Pattern; + +/** This class is generated by {@link org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/codegen/customScript") +@TestDataPath("$PROJECT_ROOT") +@RunWith(JUnit3RunnerWithInners.class) +public class IrCustomScriptCodegenTestGenerated extends AbstractIrCustomScriptCodegenTest { + private void runTest(String testDataFilePath) throws Exception { + KotlinTestUtils.runTest(this::doTest, this, testDataFilePath); + } + + public void testAllFilesPresentInCustomScript() throws Exception { + KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/codegen/customScript"), Pattern.compile("^(.*)$"), null, true); + } + + @TestMetadata("pathPattern5.kts") + public void testPathPattern5_kts() throws Exception { + runTest("compiler/testData/codegen/customScript/pathPattern5.kts"); + } + + @TestMetadata("providedPropsInLambda.kts") + public void testProvidedPropsInLambda_kts() throws Exception { + runTest("compiler/testData/codegen/customScript/providedPropsInLambda.kts"); + } + + @TestMetadata("simpleEnvVars.kts") + public void testSimpleEnvVars_kts() throws Exception { + runTest("compiler/testData/codegen/customScript/simpleEnvVars.kts"); + } + + @TestMetadata("simple.customext") + public void testSimple_customext() throws Exception { + runTest("compiler/testData/codegen/customScript/simple.customext"); + } + + @TestMetadata("stringReceiver.kts") + public void testStringReceiver_kts() throws Exception { + runTest("compiler/testData/codegen/customScript/stringReceiver.kts"); + } +} diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt index 165e3bea231..451bfba0ec2 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt @@ -12,6 +12,7 @@ import org.jetbrains.kotlin.script.loadScriptingPlugin import org.jetbrains.kotlin.scripting.compiler.plugin.configureScriptDefinitions import org.jetbrains.kotlin.test.ConfigurationKind import org.jetbrains.kotlin.test.InTextDirectivesUtils +import org.jetbrains.kotlin.test.TargetBackend import org.jetbrains.kotlin.test.TestJdkKind import org.jetbrains.kotlin.utils.PathUtil import org.jetbrains.kotlin.utils.PathUtil.KOTLIN_SCRIPTING_COMMON_JAR @@ -30,6 +31,8 @@ import kotlin.script.experimental.jvm.util.scriptCompilationClasspathFromContext abstract class AbstractCustomScriptCodegenTest : CodegenTestCase() { private lateinit var scriptDefinitions: List + override val backend = TargetBackend.JVM_OLD + override fun setUp() { super.setUp() @@ -54,6 +57,11 @@ abstract class AbstractCustomScriptCodegenTest : CodegenTestCase() { throw UnsupportedOperationException("Multiple files are not yet supported in this test") } + if (InTextDirectivesUtils.isIgnoredTarget(backend, wholeFile)) { + println("${wholeFile.name} test is skipped") + return + } + val file = files.single() val content = file.content @@ -129,6 +137,10 @@ abstract class AbstractCustomScriptCodegenTest : CodegenTestCase() { } } +abstract class AbstractIrCustomScriptCodegenTest : AbstractCustomScriptCodegenTest() { + override val backend: TargetBackend = TargetBackend.JVM_IR +} + object TestScriptWithReceiversConfiguration : ScriptCompilationConfiguration( { implicitReceivers(String::class)