Scripting, tests: enable custom script tests with IR
This commit is contained in:
committed by
Space Team
parent
ba81bd052f
commit
07af2d807a
+4
@@ -108,6 +108,10 @@ fun generateJUnit3CompilerTests(args: Array<String>) {
|
|||||||
model("codegen/customScript", pattern = "^(.*)$")
|
model("codegen/customScript", pattern = "^(.*)$")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
testClass<AbstractIrCustomScriptCodegenTest> {
|
||||||
|
model("codegen/customScript", pattern = "^(.*)$")
|
||||||
|
}
|
||||||
|
|
||||||
testClass<AbstractIrJsTextTestCase> {
|
testClass<AbstractIrJsTextTestCase> {
|
||||||
model("ir/irJsText", pattern = "^(.+)\\.kt(s)?\$")
|
model("ir/irJsText", pattern = "^(.+)\\.kt(s)?\$")
|
||||||
}
|
}
|
||||||
|
|||||||
+56
@@ -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");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import org.jetbrains.kotlin.script.loadScriptingPlugin
|
|||||||
import org.jetbrains.kotlin.scripting.compiler.plugin.configureScriptDefinitions
|
import org.jetbrains.kotlin.scripting.compiler.plugin.configureScriptDefinitions
|
||||||
import org.jetbrains.kotlin.test.ConfigurationKind
|
import org.jetbrains.kotlin.test.ConfigurationKind
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||||
|
import org.jetbrains.kotlin.test.TargetBackend
|
||||||
import org.jetbrains.kotlin.test.TestJdkKind
|
import org.jetbrains.kotlin.test.TestJdkKind
|
||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
import org.jetbrains.kotlin.utils.PathUtil.KOTLIN_SCRIPTING_COMMON_JAR
|
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() {
|
abstract class AbstractCustomScriptCodegenTest : CodegenTestCase() {
|
||||||
private lateinit var scriptDefinitions: List<String>
|
private lateinit var scriptDefinitions: List<String>
|
||||||
|
|
||||||
|
override val backend = TargetBackend.JVM_OLD
|
||||||
|
|
||||||
override fun setUp() {
|
override fun setUp() {
|
||||||
super.setUp()
|
super.setUp()
|
||||||
|
|
||||||
@@ -54,6 +57,11 @@ abstract class AbstractCustomScriptCodegenTest : CodegenTestCase() {
|
|||||||
throw UnsupportedOperationException("Multiple files are not yet supported in this test")
|
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 file = files.single()
|
||||||
val content = file.content
|
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(
|
object TestScriptWithReceiversConfiguration : ScriptCompilationConfiguration(
|
||||||
{
|
{
|
||||||
implicitReceivers(String::class)
|
implicitReceivers(String::class)
|
||||||
|
|||||||
Reference in New Issue
Block a user