[JS IR test] Add an ability to setup phases to dump after and phases to validate after in box tests using system properties

This commit is contained in:
Zalim Bashorov
2020-12-08 00:05:25 +03:00
parent ee60a1a431
commit f7b0f55532
@@ -5,6 +5,7 @@
package org.jetbrains.kotlin.js.test
import org.jetbrains.kotlin.backend.common.phaser.AnyNamedPhase
import org.jetbrains.kotlin.backend.common.phaser.PhaseConfig
import org.jetbrains.kotlin.backend.common.phaser.toPhaseMap
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
@@ -118,8 +119,8 @@ abstract class BasicIrBoxTest(
PhaseConfig(
jsPhases,
dumpToDirectory = dumpOutputDir.path,
toDumpStateAfter = allPhasesSet,
toValidateStateAfter = allPhasesSet,
toDumpStateAfter = fromSysPropertyOrAll("kotlin.js.test.phasesToDumpAfter", allPhasesSet),
toValidateStateAfter = fromSysPropertyOrAll("kotlin.js.test.phasesToValidateAfter", allPhasesSet),
dumpOnlyFqName = null
)
} else {
@@ -188,6 +189,13 @@ abstract class BasicIrBoxTest(
}
}
private fun fromSysPropertyOrAll(key: String, all: Set<AnyNamedPhase>): Set<AnyNamedPhase> {
val phases = System.getProperty(key)?.split(',')?.toSet() ?: emptySet()
if (phases.isEmpty()) return all
return all.filter { it.name in phases }.toSet()
}
private fun JsCode.writeTo(outputFile: File, config: JsConfig) {
val wrappedCode =
wrapWithModuleEmulationMarkers(mainModule, moduleId = config.moduleId, moduleKind = config.moduleKind)