[JS] Migrate multi module order test

This commit is contained in:
Ilya Goncharov
2023-06-13 16:20:49 +02:00
committed by Space Team
parent 08c04af5b5
commit b5a7b9c661
7 changed files with 28 additions and 22 deletions
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.js.test.ir.*
import org.jetbrains.kotlin.js.testOld.AbstractDceTest
import org.jetbrains.kotlin.test.TargetBackend
import org.jetbrains.kotlin.js.test.fir.AbstractFirLightTreeJsIrTextTest
import org.jetbrains.kotlin.js.test.ir.AbstractMultiModuleOrderTest
import org.jetbrains.kotlin.js.testOld.klib.AbstractClassicJsKlibEvolutionTest
import org.jetbrains.kotlin.js.testOld.klib.AbstractFirJsKlibEvolutionTest
@@ -62,22 +62,6 @@ abstract class AbstractJsTest(
}
}
open class AbstractMultiModuleOrderTest : AbstractJsTest(
pathToTestDir = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/multiModuleOrder/",
testGroupOutputDirPrefix = "multiModuleOrder/"
) {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
with(builder) {
configureJsArtifactsHandlersStep {
useHandlers(
::JsWrongModuleHandler
)
}
}
}
}
open class AbstractWebDemoExamplesTest : AbstractJsTest(
pathToTestDir = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/webDemoExamples/",
testGroupOutputDirPrefix = "webDemoExamples/"
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.js.test.handlers
import org.jetbrains.kotlin.ir.backend.js.transformers.irToJs.TranslationMode
import org.jetbrains.kotlin.js.test.utils.getTestChecker
import org.jetbrains.kotlin.test.backend.handlers.JsBinaryArtifactHandler
import org.jetbrains.kotlin.test.model.BinaryArtifacts
@@ -20,16 +21,17 @@ class JsWrongModuleHandler(testServices: TestServices) : JsBinaryArtifactHandler
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {
val originalFileName = testServices.moduleStructure.originalTestDataFiles.first().nameWithoutExtension
val parentDir = JsEnvironmentConfigurator.getJsArtifactsOutputDir(testServices)
val parentDir = JsEnvironmentConfigurator.getJsArtifactsOutputDir(testServices, translationMode = TranslationMode.PER_MODULE_DEV)
val kotlinJsFile = File(parentDir, "$originalFileName-kotlin_kotlin_v5.js").path
val mainJsFile = File(parentDir, "${originalFileName}_v5.js").path
val libJsFile = File(parentDir, "$originalFileName-lib_v5.js").path
val libJsFile = File(parentDir, "$originalFileName-kotlin_lib_v5.js").path
try {
getTestChecker(testServices).run(listOf(mainJsFile, libJsFile))
getTestChecker(testServices).run(listOf(kotlinJsFile, mainJsFile, libJsFile))
} catch (e: RuntimeException) {
testServices.assertions.assertTrue(e is IllegalStateException)
val message = e.message!!
testServices.assertions.assertTrue("'lib'" in message) {
testServices.assertions.assertTrue("'kotlin_lib'" in message) {
"Exception message should contain reference to dependency (lib)"
}
testServices.assertions.assertTrue("'main'" in message) {
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.js.test.ir
import org.jetbrains.kotlin.js.test.AbstractJsTest
import org.jetbrains.kotlin.js.test.JsSteppingTestAdditionalSourceProvider
import org.jetbrains.kotlin.js.test.converters.JsIrBackendFacade
import org.jetbrains.kotlin.js.test.converters.JsKlibBackendFacade
@@ -146,6 +147,22 @@ open class AbstractSourceMapGenerationSmokeTest : AbstractJsIrTest(
}
}
open class AbstractMultiModuleOrderTest : AbstractJsIrTest(
pathToTestDir = "${JsEnvironmentConfigurator.TEST_DATA_DIR_PATH}/multiModuleOrder/",
testGroupOutputDirPrefix = "multiModuleOrder/"
) {
override fun configure(builder: TestConfigurationBuilder) {
super.configure(builder)
with(builder) {
configureJsArtifactsHandlersStep {
useHandlers(
::JsWrongModuleHandler
)
}
}
}
}
private fun configureJsIrLineNumberTest(builder: TestConfigurationBuilder) {
with(builder) {
defaultDirectives {