JS: fix tests for -meta-info
This commit is contained in:
@@ -1,6 +1,5 @@
|
|||||||
compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt
|
compiler/testData/integration/ant/js/simpleWithoutStdlibAndFolderAsAnotherLib/jslib-example/LibraryExample.kt
|
||||||
-no-stdlib
|
-no-stdlib
|
||||||
-meta-info
|
-meta-info
|
||||||
$TEMP_DIR$/jslib-example.meta.js
|
|
||||||
-output
|
-output
|
||||||
$TEMP_DIR$/jslib-example.js
|
$TEMP_DIR$/jslib-example.js
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ where possible options include:
|
|||||||
-no-stdlib Don't use bundled Kotlin stdlib
|
-no-stdlib Don't use bundled Kotlin stdlib
|
||||||
-library-files <path[,]> Path to zipped library sources or kotlin files separated by commas
|
-library-files <path[,]> Path to zipped library sources or kotlin files separated by commas
|
||||||
-source-map Generate source map
|
-source-map Generate source map
|
||||||
-meta-info <path> Generate meta information and save to the given file
|
-meta-info Generate metadata
|
||||||
-target <version> Generate JS files for specific ECMA version (only ECMA 5 is supported)
|
-target <version> 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)
|
-main {call,noCall} Whether a main function should be called; default 'call' (main function will be auto detected)
|
||||||
-output-prefix <path> Path to file which will be added to the beginning of output file
|
-output-prefix <path> Path to file which will be added to the beginning of output file
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<target name="build">
|
<target name="build">
|
||||||
<mkdir dir="${temp.library.path}"/>
|
<mkdir dir="${temp.library.path}"/>
|
||||||
|
|
||||||
<kotlin2js src="${library.path}" output="${temp.library.path}/jslib-example.js" metaInfo="${temp.library.path}/jslib-example.meta.js"/>
|
<kotlin2js src="${library.path}" output="${temp.library.path}/jslib-example.js" metaInfo="true"/>
|
||||||
|
|
||||||
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" main="call">
|
<kotlin2js src="${test.data}/root1" output="${temp}/out.js" main="call">
|
||||||
<library>
|
<library>
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@
|
|||||||
<target name="build">
|
<target name="build">
|
||||||
<mkdir dir="${temp.library.path}"/>
|
<mkdir dir="${temp.library.path}"/>
|
||||||
|
|
||||||
<kotlin2js src="${library.path1}" output="${temp.library.path}/jslib-example1.js" metaInfo="${temp.library.path}/jslib-example1.meta.js"/>
|
<kotlin2js src="${library.path1}" output="${temp.library.path}/jslib-example1.js" metaInfo="true"/>
|
||||||
<kotlin2js src="${library.path2}" output="${temp.library.path}/jslib-example2.js" metaInfo="${temp.library.path}/jslib-example2.meta.js">
|
<kotlin2js src="${library.path2}" output="${temp.library.path}/jslib-example2.js" metaInfo="true">
|
||||||
<library>
|
<library>
|
||||||
<pathelement path="${temp.library.path}/jslib-example1.meta.js"/>
|
<pathelement path="${temp.library.path}/jslib-example1.meta.js"/>
|
||||||
</library>
|
</library>
|
||||||
|
|||||||
+2
-2
@@ -6,8 +6,8 @@
|
|||||||
<target name="build">
|
<target name="build">
|
||||||
<mkdir dir="${temp.library.path}"/>
|
<mkdir dir="${temp.library.path}"/>
|
||||||
|
|
||||||
<kotlin2js src="${library.path1}" output="${temp.library.path}/jslib-example1.js" metaInfo="${temp.library.path}/jslib-example1.meta.js"/>
|
<kotlin2js src="${library.path1}" output="${temp.library.path}/jslib-example1.js" metaInfo="true"/>
|
||||||
<kotlin2js src="${library.path2}" output="${temp.library.path}/jslib-example2.js" metaInfo="${temp.library.path}/jslib-example2.meta.js">
|
<kotlin2js src="${library.path2}" output="${temp.library.path}/jslib-example2.js" metaInfo="true">
|
||||||
<library>
|
<library>
|
||||||
<pathelement path="${temp.library.path}/jslib-example1.meta.js"/>
|
<pathelement path="${temp.library.path}/jslib-example1.meta.js"/>
|
||||||
</library>
|
</library>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<target name="build">
|
<target name="build">
|
||||||
<mkdir dir="${temp.library.path}"/>
|
<mkdir dir="${temp.library.path}"/>
|
||||||
|
|
||||||
<kotlin2js src="${library.path}" noStdlib="true" output="${temp.library.path}/jslib-example.js" metaInfo="${temp.library.path}/jslib-example.meta.js"/>
|
<kotlin2js src="${library.path}" noStdlib="true" output="${temp.library.path}/jslib-example.js" metaInfo="true"/>
|
||||||
|
|
||||||
<kotlin2js src="${test.data}/root1" noStdlib="true" output="${temp}/out.js" main="call">
|
<kotlin2js src="${test.data}/root1" noStdlib="true" output="${temp}/out.js" main="call">
|
||||||
<library>
|
<library>
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
<target name="build">
|
<target name="build">
|
||||||
<mkdir dir="${temp.library.path}"/>
|
<mkdir dir="${temp.library.path}"/>
|
||||||
|
|
||||||
<kotlin2js src="${library.path}" noStdlib="true" output="${temp.library.path}/jslib-example.js" metaInfo="${temp.library.path}/jslib-example.meta.js"/>
|
<kotlin2js src="${library.path}" noStdlib="true" output="${temp.library.path}/jslib-example.js" metaInfo="true"/>
|
||||||
|
|
||||||
<kotlin2js src="${test.data}/root1" noStdlib="true" output="${temp}/out.js" main="call">
|
<kotlin2js src="${test.data}/root1" noStdlib="true" output="${temp}/out.js" main="call">
|
||||||
<library>
|
<library>
|
||||||
|
|||||||
@@ -154,17 +154,33 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
|||||||
@NotNull Iterable<EcmaVersion> ecmaVersions,
|
@NotNull Iterable<EcmaVersion> ecmaVersions,
|
||||||
@NotNull String moduleName,
|
@NotNull String moduleName,
|
||||||
@Nullable List<String> libraries
|
@Nullable List<String> libraries
|
||||||
|
) throws Exception {
|
||||||
|
for (EcmaVersion version : ecmaVersions) {
|
||||||
|
generateJavaScriptFiles(files, testName, mainCallParameters, version, moduleName, libraries);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void generateJavaScriptFiles(
|
||||||
|
@NotNull List<String> files,
|
||||||
|
@NotNull String testName,
|
||||||
|
@NotNull MainCallParameters mainCallParameters,
|
||||||
|
@NotNull EcmaVersion version,
|
||||||
|
@NotNull String moduleName,
|
||||||
|
@Nullable List<String> libraries
|
||||||
|
|
||||||
) throws Exception {
|
) throws Exception {
|
||||||
Project project = getProject();
|
Project project = getProject();
|
||||||
List<String> allFiles = withAdditionalKotlinFiles(files);
|
List<String> allFiles = withAdditionalKotlinFiles(files);
|
||||||
List<JetFile> jetFiles = createJetFileList(project, allFiles, null);
|
List<JetFile> jetFiles = createJetFileList(project, allFiles, null);
|
||||||
|
|
||||||
for (EcmaVersion version : ecmaVersions) {
|
Config config = createConfig(getProject(), moduleName, version, libraries);
|
||||||
Config config = createConfig(getProject(), moduleName, version, libraries);
|
File outputFile = new File(getOutputFilePath(testName, version));
|
||||||
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(
|
protected void translateFiles(
|
||||||
@@ -203,9 +219,8 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
protected boolean shouldGenerateMetaInfo() {
|
||||||
protected String getMetaFileOutputPath(@NotNull String moduleId) {
|
return false;
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void processJsProgram(@NotNull JsProgram program) throws Exception { }
|
protected void processJsProgram(@NotNull JsProgram program) throws Exception { }
|
||||||
@@ -292,7 +307,7 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
|||||||
.sourceMap(shouldGenerateSourceMap())
|
.sourceMap(shouldGenerateSourceMap())
|
||||||
.inlineEnabled(IS_INLINE_ENABLED)
|
.inlineEnabled(IS_INLINE_ENABLED)
|
||||||
.isUnitTestConfig(shouldBeTranslateAsUnitTestClass())
|
.isUnitTestConfig(shouldBeTranslateAsUnitTestClass())
|
||||||
.metaFileOutputPath(getMetaFileOutputPath(moduleId))
|
.metaInfo(shouldGenerateMetaInfo())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,15 +52,20 @@ public abstract class MultipleModulesTranslationTest(main: String) : BasicTest(m
|
|||||||
private fun translateModule(dirName: String, pathToDir: String, moduleName: String, dependencies: List<String>) {
|
private fun translateModule(dirName: String, pathToDir: String, moduleName: String, dependencies: List<String>) {
|
||||||
val moduleDirectoryName = getModuleDirectoryName(dirName, moduleName)
|
val moduleDirectoryName = getModuleDirectoryName(dirName, moduleName)
|
||||||
val fullFilePaths = getAllFilesInDir(pathToDir + File.separator + moduleName)
|
val fullFilePaths = getAllFilesInDir(pathToDir + File.separator + moduleName)
|
||||||
val libraries = ArrayList<String>()
|
|
||||||
for (dependencyName in dependencies) {
|
BasicTest.DEFAULT_ECMA_VERSIONS.forEach { version ->
|
||||||
libraries.add(getMetaFileOutputPath(getModuleDirectoryName(dirName, dependencyName)))
|
val libraries = arrayListOf<String>()
|
||||||
|
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? =
|
private fun getMetaFileOutputPath(moduleDirectoryName: String, version: EcmaVersion) =
|
||||||
getOutputPath() + moduleId + KotlinJavascriptMetadataUtils.META_JS_SUFFIX
|
KotlinJavascriptMetadataUtils.replaceSuffix(getOutputFilePath(moduleDirectoryName, version))
|
||||||
|
|
||||||
|
override fun shouldGenerateMetaInfo() = true
|
||||||
|
|
||||||
override fun additionalJsFiles(ecmaVersion: EcmaVersion): List<String> {
|
override fun additionalJsFiles(ecmaVersion: EcmaVersion): List<String> {
|
||||||
val result = super.additionalJsFiles(ecmaVersion)
|
val result = super.additionalJsFiles(ecmaVersion)
|
||||||
@@ -92,7 +97,4 @@ public abstract class MultipleModulesTranslationTest(main: String) : BasicTest(m
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private fun getModuleDirectoryName(dirName: String, moduleName: String) = dirName + File.separator + moduleName
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user