[JS] Add basic optional logs to test runner
This commit is contained in:
@@ -96,6 +96,9 @@ abstract class BasicBoxTest(
|
|||||||
|
|
||||||
protected open val testChecker get() = if (runTestInNashorn) NashornJsTestChecker else V8JsTestChecker
|
protected open val testChecker get() = if (runTestInNashorn) NashornJsTestChecker else V8JsTestChecker
|
||||||
|
|
||||||
|
protected val logger = KotlinJsTestLogger()
|
||||||
|
|
||||||
|
|
||||||
fun doTest(filePath: String) {
|
fun doTest(filePath: String) {
|
||||||
doTestWithIgnoringByFailFile(filePath, coroutinesPackage = "")
|
doTestWithIgnoringByFailFile(filePath, coroutinesPackage = "")
|
||||||
}
|
}
|
||||||
@@ -119,6 +122,9 @@ abstract class BasicBoxTest(
|
|||||||
|
|
||||||
open fun doTest(filePath: String, expectedResult: String, mainCallParameters: MainCallParameters, coroutinesPackage: String = "") {
|
open fun doTest(filePath: String, expectedResult: String, mainCallParameters: MainCallParameters, coroutinesPackage: String = "") {
|
||||||
val file = File(filePath)
|
val file = File(filePath)
|
||||||
|
|
||||||
|
logger.logFile("Test file", file)
|
||||||
|
|
||||||
val outputDir = getOutputDir(file)
|
val outputDir = getOutputDir(file)
|
||||||
val dceOutputDir = getOutputDir(file, testGroupOutputDirForMinification)
|
val dceOutputDir = getOutputDir(file, testGroupOutputDirForMinification)
|
||||||
val pirOutputDir = getOutputDir(file, testGroupOutputDirForPir)
|
val pirOutputDir = getOutputDir(file, testGroupOutputDirForPir)
|
||||||
@@ -188,6 +194,8 @@ abstract class BasicBoxTest(
|
|||||||
val dceOutputFileName = module.outputFileName(dceOutputDir) + ".js"
|
val dceOutputFileName = module.outputFileName(dceOutputDir) + ".js"
|
||||||
val pirOutputFileName = module.outputFileName(pirOutputDir) + ".js"
|
val pirOutputFileName = module.outputFileName(pirOutputDir) + ".js"
|
||||||
val isMainModule = mainModuleName == module.name
|
val isMainModule = mainModuleName == module.name
|
||||||
|
|
||||||
|
logger.logFile("Output JS", File(outputFileName))
|
||||||
generateJavaScriptFile(
|
generateJavaScriptFile(
|
||||||
testFactory.tmpDir,
|
testFactory.tmpDir,
|
||||||
file.parent,
|
file.parent,
|
||||||
@@ -1115,3 +1123,13 @@ fun KotlinTestWithEnvironment.createPsiFile(fileName: String): KtFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun KotlinTestWithEnvironment.createPsiFiles(fileNames: List<String>): List<KtFile> = fileNames.map(this::createPsiFile)
|
fun KotlinTestWithEnvironment.createPsiFiles(fileNames: List<String>): List<KtFile> = fileNames.map(this::createPsiFile)
|
||||||
|
|
||||||
|
class KotlinJsTestLogger {
|
||||||
|
val verbose = getBoolean("kotlin.js.test.verbose")
|
||||||
|
|
||||||
|
fun logFile(description: String, file: File) {
|
||||||
|
if (verbose) {
|
||||||
|
println("TEST_LOG: $description file://${file.absolutePath}")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -110,12 +110,14 @@ abstract class BasicIrBoxTest(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isMainModule) {
|
if (isMainModule) {
|
||||||
|
logger.logFile("Output JS", outputFile)
|
||||||
|
|
||||||
val debugMode = getBoolean("kotlin.js.debugMode")
|
val debugMode = getBoolean("kotlin.js.debugMode")
|
||||||
|
|
||||||
val phaseConfig = if (debugMode) {
|
val phaseConfig = if (debugMode) {
|
||||||
val allPhasesSet = jsPhases.toPhaseMap().values.toSet()
|
val allPhasesSet = jsPhases.toPhaseMap().values.toSet()
|
||||||
val dumpOutputDir = File(outputFile.parent, outputFile.nameWithoutExtension + "-irdump")
|
val dumpOutputDir = File(outputFile.parent, outputFile.nameWithoutExtension + "-irdump")
|
||||||
println("\n ------ Dumping phases to file://$dumpOutputDir")
|
logger.logFile("Dumping phasesTo", dumpOutputDir)
|
||||||
PhaseConfig(
|
PhaseConfig(
|
||||||
jsPhases,
|
jsPhases,
|
||||||
dumpToDirectory = dumpOutputDir.path,
|
dumpToDirectory = dumpOutputDir.path,
|
||||||
@@ -150,8 +152,9 @@ abstract class BasicIrBoxTest(
|
|||||||
compiledModule.dceJsCode?.writeTo(dceOutputFile, config)
|
compiledModule.dceJsCode?.writeTo(dceOutputFile, config)
|
||||||
|
|
||||||
if (generateDts) {
|
if (generateDts) {
|
||||||
val dtsFile = outputFile.withReplacedExtensionOrNull("_v5.js", ".d.ts")
|
val dtsFile = outputFile.withReplacedExtensionOrNull("_v5.js", ".d.ts")!!
|
||||||
dtsFile?.write(compiledModule.tsDefinitions ?: error("No ts definitions"))
|
logger.logFile("Output d.ts", dtsFile)
|
||||||
|
dtsFile.write(compiledModule.tsDefinitions ?: error("No ts definitions"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -185,6 +188,8 @@ abstract class BasicIrBoxTest(
|
|||||||
nopack = true
|
nopack = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
logger.logFile("Output klib", File(actualOutputFile))
|
||||||
|
|
||||||
compilationCache[outputFile.name.replace(".js", ".meta.js")] = actualOutputFile
|
compilationCache[outputFile.name.replace(".js", ".meta.js")] = actualOutputFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user