[K/N][IR] Moved tests dumping to the lowering
This commit is contained in:
-3
@@ -58,9 +58,6 @@ internal class NativeGenerationState(private val context: Context) {
|
||||
getLocalClassName(source)?.let { name -> putLocalClassName(destination, name) }
|
||||
}
|
||||
|
||||
/* test suite class -> test function names */
|
||||
val testCasesToDump = mutableMapOf<ClassId, MutableCollection<String>>()
|
||||
|
||||
init {
|
||||
llvmContext = LLVMContextCreate()!!
|
||||
}
|
||||
|
||||
-25
@@ -361,29 +361,6 @@ internal val umbrellaCompilation = NamedCompilerPhase(
|
||||
}
|
||||
})
|
||||
|
||||
internal val dumpTestsPhase = makeCustomPhase<Context, IrModuleFragment>(
|
||||
name = "dumpTestsPhase",
|
||||
description = "Dump the list of all available tests",
|
||||
op = { context, _ ->
|
||||
val testDumpFile = context.config.testDumpFile
|
||||
requireNotNull(testDumpFile)
|
||||
|
||||
if (!testDumpFile.exists)
|
||||
testDumpFile.createNew()
|
||||
|
||||
if (context.generationState.testCasesToDump.isEmpty())
|
||||
return@makeCustomPhase
|
||||
|
||||
testDumpFile.appendLines(
|
||||
context.generationState.testCasesToDump
|
||||
.flatMap { (suiteClassId, functionNames) ->
|
||||
val suiteName = suiteClassId.asString()
|
||||
functionNames.asSequence().map { "$suiteName:$it" }
|
||||
}
|
||||
)
|
||||
}
|
||||
)
|
||||
|
||||
internal val entryPointPhase = makeCustomPhase<Context, IrModuleFragment>(
|
||||
name = "addEntryPoint",
|
||||
description = "Add entry point for program",
|
||||
@@ -447,7 +424,6 @@ private val backendCodegen = NamedCompilerPhase(
|
||||
allLoweringsPhase then // Lower current module first.
|
||||
dependenciesLowerPhase then // Then lower all libraries in topological order.
|
||||
// With that we guarantee that inline functions are unlowered while being inlined.
|
||||
dumpTestsPhase then
|
||||
bitcodePhase then
|
||||
verifyBitcodePhase then
|
||||
printBitcodePhase then
|
||||
@@ -566,7 +542,6 @@ internal fun PhaseConfig.konanPhasesConfig(config: KonanConfig) {
|
||||
disable(linkerPhase)
|
||||
}
|
||||
disableIf(testProcessorPhase, getNotNull(KonanConfigKeys.GENERATE_TEST_RUNNER) == TestRunnerKind.NONE)
|
||||
disableIf(dumpTestsPhase, getNotNull(KonanConfigKeys.GENERATE_TEST_RUNNER) == TestRunnerKind.NONE || config.testDumpFile == null)
|
||||
if (!config.optimizationsEnabled) {
|
||||
disable(buildDFGPhase)
|
||||
disable(devirtualizationAnalysisPhase)
|
||||
|
||||
+20
-2
@@ -65,6 +65,7 @@ internal class TestProcessor (val context: Context) {
|
||||
|
||||
// region Useful extensions.
|
||||
private var testSuiteCnt = 0
|
||||
|
||||
private fun Name.synthesizeSuiteClassName() = identifier.synthesizeSuiteClassName()
|
||||
private fun String.synthesizeSuiteClassName() = "$this\$test\$${testSuiteCnt++}".synthesizedName
|
||||
|
||||
@@ -638,11 +639,14 @@ internal class TestProcessor (val context: Context) {
|
||||
|
||||
// region test functions to be dumped
|
||||
private fun recordTestFunctions(annotationCollector: AnnotationCollector) {
|
||||
if (context.config.testDumpFile == null) return
|
||||
val testDumpFile = context.config.testDumpFile ?: return
|
||||
|
||||
/* test suite class -> test function names */
|
||||
val testCasesToDump = mutableMapOf<ClassId, MutableCollection<String>>()
|
||||
|
||||
fun recordFunction(suiteClassId: ClassId, function: TestFunction) {
|
||||
if (function.kind == FunctionKind.TEST)
|
||||
context.generationState.testCasesToDump.computeIfAbsent(suiteClassId) { mutableListOf() } += function.functionName
|
||||
testCasesToDump.computeIfAbsent(suiteClassId) { mutableListOf() } += function.functionName
|
||||
}
|
||||
|
||||
annotationCollector.topLevelFunctions.forEach { function ->
|
||||
@@ -652,6 +656,20 @@ internal class TestProcessor (val context: Context) {
|
||||
annotationCollector.testClasses.values.forEach { testClass ->
|
||||
testClass.functions.forEach { function -> recordFunction(testClass.suiteClassId, function) }
|
||||
}
|
||||
|
||||
if (!testDumpFile.exists)
|
||||
testDumpFile.createNew()
|
||||
|
||||
if (testCasesToDump.isEmpty())
|
||||
return
|
||||
|
||||
testDumpFile.appendLines(
|
||||
testCasesToDump
|
||||
.flatMap { (suiteClassId, functionNames) ->
|
||||
val suiteName = suiteClassId.asString()
|
||||
functionNames.asSequence().map { "$suiteName:$it" }
|
||||
}
|
||||
)
|
||||
}
|
||||
// endregion
|
||||
|
||||
|
||||
Reference in New Issue
Block a user