[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) }
|
getLocalClassName(source)?.let { name -> putLocalClassName(destination, name) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/* test suite class -> test function names */
|
|
||||||
val testCasesToDump = mutableMapOf<ClassId, MutableCollection<String>>()
|
|
||||||
|
|
||||||
init {
|
init {
|
||||||
llvmContext = LLVMContextCreate()!!
|
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>(
|
internal val entryPointPhase = makeCustomPhase<Context, IrModuleFragment>(
|
||||||
name = "addEntryPoint",
|
name = "addEntryPoint",
|
||||||
description = "Add entry point for program",
|
description = "Add entry point for program",
|
||||||
@@ -447,7 +424,6 @@ private val backendCodegen = NamedCompilerPhase(
|
|||||||
allLoweringsPhase then // Lower current module first.
|
allLoweringsPhase then // Lower current module first.
|
||||||
dependenciesLowerPhase then // Then lower all libraries in topological order.
|
dependenciesLowerPhase then // Then lower all libraries in topological order.
|
||||||
// With that we guarantee that inline functions are unlowered while being inlined.
|
// With that we guarantee that inline functions are unlowered while being inlined.
|
||||||
dumpTestsPhase then
|
|
||||||
bitcodePhase then
|
bitcodePhase then
|
||||||
verifyBitcodePhase then
|
verifyBitcodePhase then
|
||||||
printBitcodePhase then
|
printBitcodePhase then
|
||||||
@@ -566,7 +542,6 @@ internal fun PhaseConfig.konanPhasesConfig(config: KonanConfig) {
|
|||||||
disable(linkerPhase)
|
disable(linkerPhase)
|
||||||
}
|
}
|
||||||
disableIf(testProcessorPhase, getNotNull(KonanConfigKeys.GENERATE_TEST_RUNNER) == TestRunnerKind.NONE)
|
disableIf(testProcessorPhase, getNotNull(KonanConfigKeys.GENERATE_TEST_RUNNER) == TestRunnerKind.NONE)
|
||||||
disableIf(dumpTestsPhase, getNotNull(KonanConfigKeys.GENERATE_TEST_RUNNER) == TestRunnerKind.NONE || config.testDumpFile == null)
|
|
||||||
if (!config.optimizationsEnabled) {
|
if (!config.optimizationsEnabled) {
|
||||||
disable(buildDFGPhase)
|
disable(buildDFGPhase)
|
||||||
disable(devirtualizationAnalysisPhase)
|
disable(devirtualizationAnalysisPhase)
|
||||||
|
|||||||
+20
-2
@@ -65,6 +65,7 @@ internal class TestProcessor (val context: Context) {
|
|||||||
|
|
||||||
// region Useful extensions.
|
// region Useful extensions.
|
||||||
private var testSuiteCnt = 0
|
private var testSuiteCnt = 0
|
||||||
|
|
||||||
private fun Name.synthesizeSuiteClassName() = identifier.synthesizeSuiteClassName()
|
private fun Name.synthesizeSuiteClassName() = identifier.synthesizeSuiteClassName()
|
||||||
private fun String.synthesizeSuiteClassName() = "$this\$test\$${testSuiteCnt++}".synthesizedName
|
private fun String.synthesizeSuiteClassName() = "$this\$test\$${testSuiteCnt++}".synthesizedName
|
||||||
|
|
||||||
@@ -638,11 +639,14 @@ internal class TestProcessor (val context: Context) {
|
|||||||
|
|
||||||
// region test functions to be dumped
|
// region test functions to be dumped
|
||||||
private fun recordTestFunctions(annotationCollector: AnnotationCollector) {
|
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) {
|
fun recordFunction(suiteClassId: ClassId, function: TestFunction) {
|
||||||
if (function.kind == FunctionKind.TEST)
|
if (function.kind == FunctionKind.TEST)
|
||||||
context.generationState.testCasesToDump.computeIfAbsent(suiteClassId) { mutableListOf() } += function.functionName
|
testCasesToDump.computeIfAbsent(suiteClassId) { mutableListOf() } += function.functionName
|
||||||
}
|
}
|
||||||
|
|
||||||
annotationCollector.topLevelFunctions.forEach { function ->
|
annotationCollector.topLevelFunctions.forEach { function ->
|
||||||
@@ -652,6 +656,20 @@ internal class TestProcessor (val context: Context) {
|
|||||||
annotationCollector.testClasses.values.forEach { testClass ->
|
annotationCollector.testClasses.values.forEach { testClass ->
|
||||||
testClass.functions.forEach { function -> recordFunction(testClass.suiteClassId, function) }
|
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
|
// endregion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user