[JS IR] Append source mapping URL every time on writing JS code
Source mapping URL is not saved in JS module cache anymore, because it was a wrong url pointed to the source map from the cache. Instead, the URL is appended every time on writing the output JS code. ^KT-56469 Fixed
This commit is contained in:
committed by
Space Team
parent
e810142d74
commit
c82b4f6fe5
@@ -65,6 +65,8 @@ abstract class AbstractInvalidationTest(
|
||||
private val TEST_FILE_IGNORE_PATTERN = Regex("^.*\\..+\\.\\w\\w$")
|
||||
|
||||
private val JS_MODULE_KIND = ModuleKind.COMMON_JS
|
||||
|
||||
private const val SOURCE_MAPPING_URL_PREFIX = "//# sourceMappingURL="
|
||||
}
|
||||
|
||||
override fun createEnvironment(): KotlinCoreEnvironment {
|
||||
@@ -117,6 +119,7 @@ abstract class AbstractInvalidationTest(
|
||||
copy.put(JSConfigurationKeys.GENERATE_DTS, true)
|
||||
copy.put(JSConfigurationKeys.MODULE_KIND, JS_MODULE_KIND)
|
||||
copy.put(JSConfigurationKeys.PROPERTY_LAZY_INITIALIZATION, true)
|
||||
copy.put(JSConfigurationKeys.SOURCE_MAP, true)
|
||||
|
||||
copy.languageVersionSettings = with(LanguageVersionSettingsBuilder()) {
|
||||
language.forEach {
|
||||
@@ -246,7 +249,6 @@ abstract class AbstractInvalidationTest(
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private fun verifyJsCode(stepId: Int, mainModuleName: String, jsFiles: List<String>) {
|
||||
try {
|
||||
V8IrJsTestChecker.checkWithTestFunctionArgs(
|
||||
@@ -293,11 +295,16 @@ abstract class AbstractInvalidationTest(
|
||||
)
|
||||
}
|
||||
|
||||
private fun writeJsCode(mainModuleName: String, jsOutput: CompilationOutputs): List<String> {
|
||||
private fun writeJsCode(stepId: Int, mainModuleName: String, jsOutput: CompilationOutputs): List<String> {
|
||||
val compiledJsFiles = jsOutput.writeAll(jsDir, mainModuleName, true, mainModuleName, JS_MODULE_KIND).filter {
|
||||
it.extension == "js"
|
||||
}
|
||||
for (jsCodeFile in compiledJsFiles) {
|
||||
val sourceMappingUrlLine = jsCodeFile.readLines().singleOrNull { it.startsWith(SOURCE_MAPPING_URL_PREFIX) }
|
||||
JUnit4Assertions.assertEquals("$SOURCE_MAPPING_URL_PREFIX${jsCodeFile.name}.map", sourceMappingUrlLine) {
|
||||
"Mismatched source map url at step $stepId"
|
||||
}
|
||||
|
||||
jsCodeFile.writeAsJsModule(jsCodeFile.readText(), "./${jsCodeFile.name}")
|
||||
}
|
||||
|
||||
@@ -349,7 +356,7 @@ abstract class AbstractInvalidationTest(
|
||||
)
|
||||
|
||||
val (jsOutput, rebuiltModules) = jsExecutableProducer.buildExecutable(multiModule = true, outJsProgram = true)
|
||||
val writtenFiles = writeJsCode(mainModuleName, jsOutput)
|
||||
val writtenFiles = writeJsCode(projStep.id, mainModuleName, jsOutput)
|
||||
|
||||
verifyJsExecutableProducerBuildModules(projStep.id, rebuiltModules, projStep.dirtyJS)
|
||||
verifyJsCode(projStep.id, mainModuleName, writtenFiles)
|
||||
|
||||
Reference in New Issue
Block a user