From 33cdf8c9696896baef5a349698f74f31ce83743c Mon Sep 17 00:00:00 2001 From: Michael Nedzelsky Date: Tue, 20 Jan 2015 18:36:14 +0300 Subject: [PATCH] JS backend: add cli test for creating metadata and ant test for library with metadata --- compiler/testData/cli/js/createMetadata.args | 6 +++++ compiler/testData/cli/js/createMetadata.out | 1 + .../build.log.expected | 13 +++++++++++ .../build.xml | 22 +++++++++++++++++++ .../jslib-example/LibraryExample.kt | 6 +++++ .../jslib-example/META-INF/MANIFEST.MF | 9 ++++++++ .../root1/foo.kt | 14 ++++++++++++ .../cli/KotlincExecutableTestGenerated.java | 6 +++++ .../jetbrains/kotlin/cli/js/K2JsCliTest.java | 8 +++++++ .../kotlin/integration/AntTaskJsTest.java | 5 +++++ 10 files changed, 90 insertions(+) create mode 100644 compiler/testData/cli/js/createMetadata.args create mode 100644 compiler/testData/cli/js/createMetadata.out create mode 100644 compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.log.expected create mode 100644 compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml create mode 100644 compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt create mode 100644 compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF create mode 100644 compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/root1/foo.kt diff --git a/compiler/testData/cli/js/createMetadata.args b/compiler/testData/cli/js/createMetadata.args new file mode 100644 index 00000000000..4d7186aa107 --- /dev/null +++ b/compiler/testData/cli/js/createMetadata.args @@ -0,0 +1,6 @@ +compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt +-no-stdlib +-meta-info +$TEMP_DIR$/jslib-example.meta.js +-output +$TEMP_DIR$/jslib-example.js diff --git a/compiler/testData/cli/js/createMetadata.out b/compiler/testData/cli/js/createMetadata.out new file mode 100644 index 00000000000..d86bac9de59 --- /dev/null +++ b/compiler/testData/cli/js/createMetadata.out @@ -0,0 +1 @@ +OK diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.log.expected b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.log.expected new file mode 100644 index 00000000000..c36a7c11434 --- /dev/null +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.log.expected @@ -0,0 +1,13 @@ +OUT: +Buildfile: [TestData]/build.xml + +build: + [mkdir] Created dir: [Temp]/lib +[kotlin2js] Compiling [[TestData]/jslib-example] => [[Temp]/lib/jslib-example.js] +[kotlin2js] Compiling [[TestData]/root1] => [[Temp]/out.js] + [copy] Copying 2 files to [Temp] + +BUILD SUCCESSFUL +Total time: [time] + +Return code: 0 diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml new file mode 100644 index 00000000000..d007b8780e5 --- /dev/null +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt new file mode 100644 index 00000000000..faf1e678458 --- /dev/null +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt @@ -0,0 +1,6 @@ +package library.sample + +public class ClassA() { + val value: Int = 100 +} + diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..6bdb182f242 --- /dev/null +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Ant-Version: Apache Ant 1.9.1 +Created-By: 1.7.0_72-b14 (Oracle Corporation) +Built-By: JetBrains +Implementation-Vendor: JetBrains +Implementation-Version: snapshot +Specification-Title: Kotlin JavaScript Lib + + diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/root1/foo.kt b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/root1/foo.kt new file mode 100644 index 00000000000..c2ddea45024 --- /dev/null +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/root1/foo.kt @@ -0,0 +1,14 @@ +package foo + +import library.sample.* + +var ok = "FAIL" + +fun main(args: Array) { + val x = ClassA().value + if (x == 100) { + ok = "OK" + } +} + +fun box(): String = ok diff --git a/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java index 272a8edd534..08a4e3b43e3 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cli/KotlincExecutableTestGenerated.java @@ -183,6 +183,12 @@ public class KotlincExecutableTestGenerated extends AbstractKotlincExecutableTes JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/cli/js"), Pattern.compile("^(.+)\\.args$"), false); } + @TestMetadata("createMetadata.args") + public void testCreateMetadata() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/js/createMetadata.args"); + doJsTest(fileName); + } + @TestMetadata("diagnosticForClassLiteral.args") public void testDiagnosticForClassLiteral() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/cli/js/diagnosticForClassLiteral.args"); diff --git a/compiler/tests/org/jetbrains/kotlin/cli/js/K2JsCliTest.java b/compiler/tests/org/jetbrains/kotlin/cli/js/K2JsCliTest.java index bc17f881f33..5d99e5c85b4 100644 --- a/compiler/tests/org/jetbrains/kotlin/cli/js/K2JsCliTest.java +++ b/compiler/tests/org/jetbrains/kotlin/cli/js/K2JsCliTest.java @@ -70,6 +70,14 @@ public class K2JsCliTest extends CliBaseTest { Assert.assertTrue(new File(tmpdir.getTmpDir(), "out.js").isFile()); } + @Test + public void createMetadata() throws Exception { + executeCompilerCompareOutputJS(); + + Assert.assertTrue(new File(tmpdir.getTmpDir(), "jslib-example.meta.js").isFile()); + Assert.assertTrue(new File(tmpdir.getTmpDir(), "jslib-example.js").isFile()); + } + @Test public void libraryDirNotFound() throws Exception { executeCompilerCompareOutputJS(); diff --git a/compiler/tests/org/jetbrains/kotlin/integration/AntTaskJsTest.java b/compiler/tests/org/jetbrains/kotlin/integration/AntTaskJsTest.java index 90ee9173cc7..a4b32f8fafa 100644 --- a/compiler/tests/org/jetbrains/kotlin/integration/AntTaskJsTest.java +++ b/compiler/tests/org/jetbrains/kotlin/integration/AntTaskJsTest.java @@ -112,6 +112,11 @@ public class AntTaskJsTest extends AntTaskBaseTest { doJsAntTest("jslib-example.js"); } + @Test + public void simpleWithoutStdlibAndFolderAsAnotherLib() throws Exception { + doJsAntTest("jslib-example.js"); + } + @Test public void simpleWithMainFQArgs() throws Exception { doJsAntTest();