From 01dd665441303b08de64972ddb3ac7d7630517a1 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Fri, 10 Aug 2018 14:36:32 +0200 Subject: [PATCH] Simple test for non-kts script compilation --- .../testData/codegen/customScript/simple.customext | 8 ++++++++ .../kotlin/codegen/AbstractCustomScriptCodegenTest.kt | 4 ++++ .../codegen/CustomScriptCodegenTestGenerated.java | 11 ++++++++--- .../kotlin/generators/tests/GenerateCompilerTests.kt | 2 +- 4 files changed, 21 insertions(+), 4 deletions(-) create mode 100644 compiler/testData/codegen/customScript/simple.customext diff --git a/compiler/testData/codegen/customScript/simple.customext b/compiler/testData/codegen/customScript/simple.customext new file mode 100644 index 00000000000..6734c3ca02e --- /dev/null +++ b/compiler/testData/codegen/customScript/simple.customext @@ -0,0 +1,8 @@ + +// KOTLIN_SCRIPT_DEFINITION: org.jetbrains.kotlin.codegen.TestScriptWithNonKtsExtension + +// param: world + +val res = "Hello $name" + +// expected: res=Hello world diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt index 4eec87c821d..4ef57c9800f 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt +++ b/compiler/tests/org/jetbrains/kotlin/codegen/AbstractCustomScriptCodegenTest.kt @@ -138,3 +138,7 @@ object TestScriptWithSimpleEnvVarsConfiguration : ScriptCompilationConfiguration @Suppress("unused") @KotlinScript(compilationConfiguration = TestScriptWithSimpleEnvVarsConfiguration::class) abstract class TestScriptWithSimpleEnvVars + +@Suppress("unused") +@KotlinScript(extension = "customext") +abstract class TestScriptWithNonKtsExtension(val name: String) diff --git a/compiler/tests/org/jetbrains/kotlin/codegen/CustomScriptCodegenTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/codegen/CustomScriptCodegenTestGenerated.java index c381c528316..7ca309d37b1 100644 --- a/compiler/tests/org/jetbrains/kotlin/codegen/CustomScriptCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/codegen/CustomScriptCodegenTestGenerated.java @@ -26,16 +26,21 @@ public class CustomScriptCodegenTestGenerated extends AbstractCustomScriptCodege } public void testAllFilesPresentInCustomScript() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/customScript"), Pattern.compile("^(.+)\\.kts$"), TargetBackend.ANY, true); + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/customScript"), Pattern.compile("^(.*)$"), TargetBackend.ANY, true); } @TestMetadata("simpleEnvVars.kts") - public void testSimpleEnvVars() throws Exception { + 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() throws Exception { + public void testStringReceiver_kts() throws Exception { runTest("compiler/testData/codegen/customScript/stringReceiver.kts"); } } diff --git a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt index 3668115aa27..f113308608b 100644 --- a/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt +++ b/compiler/tests/org/jetbrains/kotlin/generators/tests/GenerateCompilerTests.kt @@ -169,7 +169,7 @@ fun main(args: Array) { } testClass { - model("codegen/customScript", extension = "kts") + model("codegen/customScript", pattern = "^(.*)$") } testClass {