diff --git a/compiler/testData/cli/js/createMetadata.args b/compiler/testData/cli/js/createMetadata.args index 4d7186aa107..8ea42e28941 100644 --- a/compiler/testData/cli/js/createMetadata.args +++ b/compiler/testData/cli/js/createMetadata.args @@ -1,6 +1,5 @@ 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/jsHelp.out b/compiler/testData/cli/js/jsHelp.out index f84ab69da76..b75d28fd799 100644 --- a/compiler/testData/cli/js/jsHelp.out +++ b/compiler/testData/cli/js/jsHelp.out @@ -4,7 +4,7 @@ where possible options include: -no-stdlib Don't use bundled Kotlin stdlib -library-files Path to zipped library sources or kotlin files separated by commas -source-map Generate source map - -meta-info Generate meta information and save to the given file + -meta-info Generate metadata -target Generate JS files for specific ECMA version (only ECMA 5 is supported) -main {call,noCall} Whether a main function should be called; default 'call' (main function will be auto detected) -output-prefix Path to file which will be added to the beginning of output file diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndJsFileAsAnotherLib/build.xml b/compiler/testData/integration/ant/js/simpleWithStdlibAndJsFileAsAnotherLib/build.xml index 7c158229d52..e209ab0c022 100644 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndJsFileAsAnotherLib/build.xml +++ b/compiler/testData/integration/ant/js/simpleWithStdlibAndJsFileAsAnotherLib/build.xml @@ -5,7 +5,7 @@ - + diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndJsFilesWithTwoModulesAsLibrary/build.xml b/compiler/testData/integration/ant/js/simpleWithStdlibAndJsFilesWithTwoModulesAsLibrary/build.xml index dd3671f4f93..b87acebf748 100644 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndJsFilesWithTwoModulesAsLibrary/build.xml +++ b/compiler/testData/integration/ant/js/simpleWithStdlibAndJsFilesWithTwoModulesAsLibrary/build.xml @@ -6,8 +6,8 @@ - - + + diff --git a/compiler/testData/integration/ant/js/simpleWithStdlibAndTwoJsFilesAsLibraries/build.xml b/compiler/testData/integration/ant/js/simpleWithStdlibAndTwoJsFilesAsLibraries/build.xml index 1f0cb9d5176..f408fc39827 100644 --- a/compiler/testData/integration/ant/js/simpleWithStdlibAndTwoJsFilesAsLibraries/build.xml +++ b/compiler/testData/integration/ant/js/simpleWithStdlibAndTwoJsFilesAsLibraries/build.xml @@ -6,8 +6,8 @@ - - + + diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml index 75089686103..74476909e4e 100644 --- a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/build.xml @@ -5,7 +5,7 @@ - + diff --git a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.xml b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.xml index fc7fe550f84..4b7a0a0eecf 100644 --- a/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.xml +++ b/compiler/testData/integration/ant/js/simpleWithoutStdlibAndJsFileAsAnotherLib/build.xml @@ -5,7 +5,7 @@ - + diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicTest.java b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicTest.java index 15714a68589..bd4367c7f27 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicTest.java +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/BasicTest.java @@ -154,17 +154,33 @@ public abstract class BasicTest extends KotlinTestWithEnvironment { @NotNull Iterable ecmaVersions, @NotNull String moduleName, @Nullable List libraries + ) throws Exception { + for (EcmaVersion version : ecmaVersions) { + generateJavaScriptFiles(files, testName, mainCallParameters, version, moduleName, libraries); + } + } + + protected void generateJavaScriptFiles( + @NotNull List files, + @NotNull String testName, + @NotNull MainCallParameters mainCallParameters, + @NotNull EcmaVersion version, + @NotNull String moduleName, + @Nullable List libraries + ) throws Exception { Project project = getProject(); List allFiles = withAdditionalKotlinFiles(files); List jetFiles = createJetFileList(project, allFiles, null); - for (EcmaVersion version : ecmaVersions) { - Config config = createConfig(getProject(), moduleName, version, libraries); - File outputFile = new File(getOutputFilePath(testName, version)); + Config config = createConfig(getProject(), moduleName, version, libraries); + File outputFile = new File(getOutputFilePath(testName, version)); - translateFiles(jetFiles, outputFile, mainCallParameters, config); - } + translateFiles(jetFiles, outputFile, mainCallParameters, config); + } + + protected String getModuleDirectoryName(String dirName, String moduleName) { + return dirName + File.separator + moduleName; } protected void translateFiles( @@ -203,9 +219,8 @@ public abstract class BasicTest extends KotlinTestWithEnvironment { return false; } - @Nullable - protected String getMetaFileOutputPath(@NotNull String moduleId) { - return null; + protected boolean shouldGenerateMetaInfo() { + return false; } protected void processJsProgram(@NotNull JsProgram program) throws Exception { } @@ -292,7 +307,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment { .sourceMap(shouldGenerateSourceMap()) .inlineEnabled(IS_INLINE_ENABLED) .isUnitTestConfig(shouldBeTranslateAsUnitTestClass()) - .metaFileOutputPath(getMetaFileOutputPath(moduleId)) + .metaInfo(shouldGenerateMetaInfo()) .build(); } diff --git a/js/js.tests/test/org/jetbrains/kotlin/js/test/MultipleModulesTranslationTest.kt b/js/js.tests/test/org/jetbrains/kotlin/js/test/MultipleModulesTranslationTest.kt index 07b02e6211c..2e801d69392 100644 --- a/js/js.tests/test/org/jetbrains/kotlin/js/test/MultipleModulesTranslationTest.kt +++ b/js/js.tests/test/org/jetbrains/kotlin/js/test/MultipleModulesTranslationTest.kt @@ -52,15 +52,20 @@ public abstract class MultipleModulesTranslationTest(main: String) : BasicTest(m private fun translateModule(dirName: String, pathToDir: String, moduleName: String, dependencies: List) { val moduleDirectoryName = getModuleDirectoryName(dirName, moduleName) val fullFilePaths = getAllFilesInDir(pathToDir + File.separator + moduleName) - val libraries = ArrayList() - for (dependencyName in dependencies) { - libraries.add(getMetaFileOutputPath(getModuleDirectoryName(dirName, dependencyName))) + + BasicTest.DEFAULT_ECMA_VERSIONS.forEach { version -> + val libraries = arrayListOf() + for (dependencyName in dependencies) { + libraries.add(getMetaFileOutputPath(getModuleDirectoryName(dirName, dependencyName), version)) + } + generateJavaScriptFiles(fullFilePaths, moduleDirectoryName, MainCallParameters.noCall(), version, moduleName, libraries) } - generateJavaScriptFiles(fullFilePaths, moduleDirectoryName, MainCallParameters.noCall(), BasicTest.DEFAULT_ECMA_VERSIONS, moduleName, libraries) } - override fun getMetaFileOutputPath(moduleId: String): String? = - getOutputPath() + moduleId + KotlinJavascriptMetadataUtils.META_JS_SUFFIX + private fun getMetaFileOutputPath(moduleDirectoryName: String, version: EcmaVersion) = + KotlinJavascriptMetadataUtils.replaceSuffix(getOutputFilePath(moduleDirectoryName, version)) + + override fun shouldGenerateMetaInfo() = true override fun additionalJsFiles(ecmaVersion: EcmaVersion): List { val result = super.additionalJsFiles(ecmaVersion) @@ -92,7 +97,4 @@ public abstract class MultipleModulesTranslationTest(main: String) : BasicTest(m return result } - - - private fun getModuleDirectoryName(dirName: String, moduleName: String) = dirName + File.separator + moduleName }