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
|
||||
-no-stdlib
|
||||
-meta-info
|
||||
$TEMP_DIR$/jslib-example.meta.js
|
||||
-output
|
||||
$TEMP_DIR$/jslib-example.js
|
||||
|
||||
@@ -4,7 +4,7 @@ where possible options include:
|
||||
-no-stdlib Don't use bundled Kotlin stdlib
|
||||
-library-files <path[,]> Path to zipped library sources or kotlin files separated by commas
|
||||
-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)
|
||||
-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
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<target name="build">
|
||||
<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">
|
||||
<library>
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
<target name="build">
|
||||
<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.path2}" output="${temp.library.path}/jslib-example2.js" metaInfo="${temp.library.path}/jslib-example2.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="true">
|
||||
<library>
|
||||
<pathelement path="${temp.library.path}/jslib-example1.meta.js"/>
|
||||
</library>
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
<target name="build">
|
||||
<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.path2}" output="${temp.library.path}/jslib-example2.js" metaInfo="${temp.library.path}/jslib-example2.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="true">
|
||||
<library>
|
||||
<pathelement path="${temp.library.path}/jslib-example1.meta.js"/>
|
||||
</library>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<target name="build">
|
||||
<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">
|
||||
<library>
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<target name="build">
|
||||
<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">
|
||||
<library>
|
||||
|
||||
@@ -154,17 +154,33 @@ public abstract class BasicTest extends KotlinTestWithEnvironment {
|
||||
@NotNull Iterable<EcmaVersion> ecmaVersions,
|
||||
@NotNull String moduleName,
|
||||
@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 {
|
||||
Project project = getProject();
|
||||
List<String> allFiles = withAdditionalKotlinFiles(files);
|
||||
List<JetFile> 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();
|
||||
}
|
||||
|
||||
|
||||
@@ -52,15 +52,20 @@ public abstract class MultipleModulesTranslationTest(main: String) : BasicTest(m
|
||||
private fun translateModule(dirName: String, pathToDir: String, moduleName: String, dependencies: List<String>) {
|
||||
val moduleDirectoryName = getModuleDirectoryName(dirName, moduleName)
|
||||
val fullFilePaths = getAllFilesInDir(pathToDir + File.separator + moduleName)
|
||||
val libraries = ArrayList<String>()
|
||||
for (dependencyName in dependencies) {
|
||||
libraries.add(getMetaFileOutputPath(getModuleDirectoryName(dirName, dependencyName)))
|
||||
|
||||
BasicTest.DEFAULT_ECMA_VERSIONS.forEach { version ->
|
||||
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? =
|
||||
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<String> {
|
||||
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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user