[JS IR] Lazy initialisation is optional for tests
^KT-43222 fixed
This commit is contained in:
+2
@@ -18,6 +18,8 @@ where advanced options include:
|
|||||||
-Xir-produce-klib-dir Generate unpacked KLIB into parent directory of output JS file.
|
-Xir-produce-klib-dir Generate unpacked KLIB into parent directory of output JS file.
|
||||||
In combination with -meta-info generates both IR and pre-IR versions of library.
|
In combination with -meta-info generates both IR and pre-IR versions of library.
|
||||||
-Xir-produce-klib-file Generate packed klib into file specified by -output. Disables pre-IR backend
|
-Xir-produce-klib-file Generate packed klib into file specified by -output. Disables pre-IR backend
|
||||||
|
-Xir-property-lazy-initialisation
|
||||||
|
Perform lazy initialisation for properties
|
||||||
-Xmetadata-only Generate *.meta.js and *.kjsm files only
|
-Xmetadata-only Generate *.meta.js and *.kjsm files only
|
||||||
-Xtyped-arrays Translate primitive arrays to JS typed arrays
|
-Xtyped-arrays Translate primitive arrays to JS typed arrays
|
||||||
-Xwasm Use experimental WebAssembly compiler backend
|
-Xwasm Use experimental WebAssembly compiler backend
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
// IGNORE_BACKEND: JS, NATIVE
|
// IGNORE_BACKEND: JS, NATIVE
|
||||||
// DONT_TARGET_EXACT_BACKEND: WASM
|
// DONT_TARGET_EXACT_BACKEND: WASM
|
||||||
|
// PROPERTY_LAZY_INITIALISATION
|
||||||
|
|
||||||
// FILE: A.kt
|
// FILE: A.kt
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// TARGET_BACKEND: JS_IR
|
// TARGET_BACKEND: JS_IR
|
||||||
|
// PROPERTY_LAZY_INITIALISATION
|
||||||
|
|
||||||
// FILE: A.kt
|
// FILE: A.kt
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// IGNORE_BACKEND_FIR: JVM_IR
|
// IGNORE_BACKEND_FIR: JVM_IR
|
||||||
// IGNORE_BACKEND: JVM, JVM_IR, JS_IR
|
// IGNORE_BACKEND: JVM, JVM_IR
|
||||||
// IGNORE_LIGHT_ANALYSIS
|
// IGNORE_LIGHT_ANALYSIS
|
||||||
// MODULE: lib1
|
// MODULE: lib1
|
||||||
// FILE: lib1.kt
|
// FILE: lib1.kt
|
||||||
|
|||||||
@@ -131,6 +131,8 @@ abstract class BasicBoxTest(
|
|||||||
val skipDceDriven = SKIP_DCE_DRIVEN.matcher(fileContent).find()
|
val skipDceDriven = SKIP_DCE_DRIVEN.matcher(fileContent).find()
|
||||||
val splitPerModule = SPLIT_PER_MODULE.matcher(fileContent).find()
|
val splitPerModule = SPLIT_PER_MODULE.matcher(fileContent).find()
|
||||||
|
|
||||||
|
val propertyLazyInitialization = PROPERTY_LAZY_INITIALISATION.matcher(fileContent).find()
|
||||||
|
|
||||||
TestFileFactoryImpl(coroutinesPackage).use { testFactory ->
|
TestFileFactoryImpl(coroutinesPackage).use { testFactory ->
|
||||||
val inputFiles = TestFiles.createTestFiles(
|
val inputFiles = TestFiles.createTestFiles(
|
||||||
file.name,
|
file.name,
|
||||||
@@ -172,9 +174,28 @@ abstract class BasicBoxTest(
|
|||||||
val isMainModule = mainModuleName == module.name
|
val isMainModule = mainModuleName == module.name
|
||||||
generateJavaScriptFile(
|
generateJavaScriptFile(
|
||||||
testFactory.tmpDir,
|
testFactory.tmpDir,
|
||||||
file.parent, module, outputFileName, dceOutputFileName, pirOutputFileName, dependencies, allDependencies, friends, modules.size > 1,
|
file.parent,
|
||||||
!SKIP_SOURCEMAP_REMAPPING.matcher(fileContent).find(), outputPrefixFile, outputPostfixFile,
|
module,
|
||||||
actualMainCallParameters, testPackage, testFunction, needsFullIrRuntime, isMainModule, expectActualLinker, skipDceDriven, splitPerModule, errorPolicy
|
outputFileName,
|
||||||
|
dceOutputFileName,
|
||||||
|
pirOutputFileName,
|
||||||
|
dependencies,
|
||||||
|
allDependencies,
|
||||||
|
friends,
|
||||||
|
modules.size > 1,
|
||||||
|
!SKIP_SOURCEMAP_REMAPPING.matcher(fileContent).find(),
|
||||||
|
outputPrefixFile,
|
||||||
|
outputPostfixFile,
|
||||||
|
actualMainCallParameters,
|
||||||
|
testPackage,
|
||||||
|
testFunction,
|
||||||
|
needsFullIrRuntime,
|
||||||
|
isMainModule,
|
||||||
|
expectActualLinker,
|
||||||
|
skipDceDriven,
|
||||||
|
splitPerModule,
|
||||||
|
errorPolicy,
|
||||||
|
propertyLazyInitialization
|
||||||
)
|
)
|
||||||
|
|
||||||
when {
|
when {
|
||||||
@@ -398,7 +419,8 @@ abstract class BasicBoxTest(
|
|||||||
expectActualLinker: Boolean,
|
expectActualLinker: Boolean,
|
||||||
skipDceDriven: Boolean,
|
skipDceDriven: Boolean,
|
||||||
splitPerModule: Boolean,
|
splitPerModule: Boolean,
|
||||||
errorIgnorancePolicy: ErrorTolerancePolicy
|
errorIgnorancePolicy: ErrorTolerancePolicy,
|
||||||
|
propertyLazyInitialisation: Boolean,
|
||||||
) {
|
) {
|
||||||
val kotlinFiles = module.files.filter { it.fileName.endsWith(".kt") }
|
val kotlinFiles = module.files.filter { it.fileName.endsWith(".kt") }
|
||||||
val testFiles = kotlinFiles.map { it.fileName }
|
val testFiles = kotlinFiles.map { it.fileName }
|
||||||
@@ -414,7 +436,19 @@ abstract class BasicBoxTest(
|
|||||||
val psiFiles = createPsiFiles(allSourceFiles.sortedBy { it.canonicalPath }.map { it.canonicalPath })
|
val psiFiles = createPsiFiles(allSourceFiles.sortedBy { it.canonicalPath }.map { it.canonicalPath })
|
||||||
|
|
||||||
val sourceDirs = (testFiles + additionalFiles).map { File(it).parent }.distinct()
|
val sourceDirs = (testFiles + additionalFiles).map { File(it).parent }.distinct()
|
||||||
val config = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData = null, expectActualLinker = expectActualLinker, errorIgnorancePolicy)
|
val config = createConfig(
|
||||||
|
sourceDirs,
|
||||||
|
module,
|
||||||
|
dependencies,
|
||||||
|
allDependencies,
|
||||||
|
friends,
|
||||||
|
multiModule,
|
||||||
|
tmpDir,
|
||||||
|
incrementalData = null,
|
||||||
|
expectActualLinker = expectActualLinker,
|
||||||
|
errorIgnorancePolicy,
|
||||||
|
propertyLazyInitialisation
|
||||||
|
)
|
||||||
val outputFile = File(outputFileName)
|
val outputFile = File(outputFileName)
|
||||||
val dceOutputFile = File(dceOutputFileName)
|
val dceOutputFile = File(dceOutputFileName)
|
||||||
val pirOutputFile = File(pirOutputFileName)
|
val pirOutputFile = File(pirOutputFileName)
|
||||||
@@ -469,7 +503,19 @@ abstract class BasicBoxTest(
|
|||||||
.sortedBy { it.canonicalPath }
|
.sortedBy { it.canonicalPath }
|
||||||
.map { sourceToTranslationUnit[it]!! }
|
.map { sourceToTranslationUnit[it]!! }
|
||||||
|
|
||||||
val recompiledConfig = createConfig(sourceDirs, module, dependencies, allDependencies, friends, multiModule, tmpDir, incrementalData, expectActualLinker, ErrorTolerancePolicy.DEFAULT)
|
val recompiledConfig = createConfig(
|
||||||
|
sourceDirs,
|
||||||
|
module,
|
||||||
|
dependencies,
|
||||||
|
allDependencies,
|
||||||
|
friends,
|
||||||
|
multiModule,
|
||||||
|
tmpDir,
|
||||||
|
incrementalData,
|
||||||
|
expectActualLinker,
|
||||||
|
ErrorTolerancePolicy.DEFAULT,
|
||||||
|
propertyLazyInitialisation = false
|
||||||
|
)
|
||||||
val recompiledOutputFile = File(outputFile.parentFile, outputFile.nameWithoutExtension + "-recompiled.js")
|
val recompiledOutputFile = File(outputFile.parentFile, outputFile.nameWithoutExtension + "-recompiled.js")
|
||||||
|
|
||||||
translateFiles(
|
translateFiles(
|
||||||
@@ -684,8 +730,17 @@ abstract class BasicBoxTest(
|
|||||||
private fun createPsiFiles(fileNames: List<String>): List<KtFile> = fileNames.map(this::createPsiFile)
|
private fun createPsiFiles(fileNames: List<String>): List<KtFile> = fileNames.map(this::createPsiFile)
|
||||||
|
|
||||||
private fun createConfig(
|
private fun createConfig(
|
||||||
sourceDirs: List<String>, module: TestModule, dependencies: List<String>, allDependencies: List<String>, friends: List<String>,
|
sourceDirs: List<String>,
|
||||||
multiModule: Boolean, tmpDir: File, incrementalData: IncrementalData?, expectActualLinker: Boolean, errorIgnorancePolicy: ErrorTolerancePolicy
|
module: TestModule,
|
||||||
|
dependencies: List<String>,
|
||||||
|
allDependencies: List<String>,
|
||||||
|
friends: List<String>,
|
||||||
|
multiModule: Boolean,
|
||||||
|
tmpDir: File,
|
||||||
|
incrementalData: IncrementalData?,
|
||||||
|
expectActualLinker: Boolean,
|
||||||
|
errorIgnorancePolicy: ErrorTolerancePolicy,
|
||||||
|
propertyLazyInitialisation: Boolean,
|
||||||
): JsConfig {
|
): JsConfig {
|
||||||
val configuration = environment.configuration.copy()
|
val configuration = environment.configuration.copy()
|
||||||
|
|
||||||
@@ -709,6 +764,7 @@ abstract class BasicBoxTest(
|
|||||||
configuration.put(JSConfigurationKeys.MODULE_KIND, module.moduleKind)
|
configuration.put(JSConfigurationKeys.MODULE_KIND, module.moduleKind)
|
||||||
configuration.put(JSConfigurationKeys.TARGET, EcmaVersion.v5)
|
configuration.put(JSConfigurationKeys.TARGET, EcmaVersion.v5)
|
||||||
configuration.put(JSConfigurationKeys.ERROR_TOLERANCE_POLICY, errorIgnorancePolicy)
|
configuration.put(JSConfigurationKeys.ERROR_TOLERANCE_POLICY, errorIgnorancePolicy)
|
||||||
|
configuration.put(JSConfigurationKeys.PROPERTY_LAZY_INITIALISATION, propertyLazyInitialisation)
|
||||||
|
|
||||||
if (errorIgnorancePolicy.allowErrors) {
|
if (errorIgnorancePolicy.allowErrors) {
|
||||||
configuration.put(JSConfigurationKeys.DEVELOPER_MODE, true)
|
configuration.put(JSConfigurationKeys.DEVELOPER_MODE, true)
|
||||||
@@ -942,6 +998,8 @@ abstract class BasicBoxTest(
|
|||||||
|
|
||||||
private val ERROR_POLICY_PATTERN = Pattern.compile("^// *ERROR_POLICY: *(.+)$", Pattern.MULTILINE)
|
private val ERROR_POLICY_PATTERN = Pattern.compile("^// *ERROR_POLICY: *(.+)$", Pattern.MULTILINE)
|
||||||
|
|
||||||
|
private val PROPERTY_LAZY_INITIALISATION = Pattern.compile("^// *PROPERTY_LAZY_INITIALISATION *$", Pattern.MULTILINE)
|
||||||
|
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
protected val runTestInNashorn = getBoolean("kotlin.js.useNashorn")
|
protected val runTestInNashorn = getBoolean("kotlin.js.useNashorn")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user