[FIR] Move reporting of errors in modularized tests in separate log file

This commit is contained in:
Dmitriy Novozhilov
2019-09-12 10:32:38 +03:00
parent 5dc29b9059
commit c2180b9361
2 changed files with 17 additions and 13 deletions
@@ -129,7 +129,7 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
override fun afterPass(pass: Int) {
val statistics = bench.getTotalStatistics()
statistics.report(System.out, "Pass $pass", errorTypeReports = false)
statistics.report(System.out, "Pass $pass")
saveReport(pass, statistics)
if (statistics.totalTime < (bestStatistics?.totalTime ?: Long.MAX_VALUE)) {
@@ -143,7 +143,8 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
override fun afterAllPasses() {
val bestStatistics = bestStatistics ?: return
printStatistics(bestStatistics, "Best pass: $bestPass", false)
printStatistics(bestStatistics, "Best pass: $bestPass")
printErrors(bestStatistics)
}
private val folderDateFormat = SimpleDateFormat("yyyy-MM-dd")
@@ -169,15 +170,17 @@ class FirResolveModularizedTotalKotlinTest : AbstractModularizedTest() {
printStatistics(statistics, "PASS $pass")
}
private fun printStatistics(statistics: FirResolveBench.TotalStatistics, header: String, errorTypeReports: Boolean = true) {
private fun printErrors(statistics: FirResolveBench.TotalStatistics) {
PrintStream(FileOutputStream(reportDir().resolve("errors-$reportDateStr.log"), true)).use(statistics::reportErrors)
}
private fun printStatistics(statistics: FirResolveBench.TotalStatistics, header: String) {
PrintStream(
FileOutputStream(
reportDir().resolve("report-$reportDateStr.log"),
true
)
).use { stream ->
val sep = "=".repeat(10)
stream.println("$sep $header $sep")
statistics.report(stream, header)
stream.println()
stream.println()
@@ -319,19 +319,20 @@ fun <T> Collection<T>.progress(step: Double = 0.1, computeLabel: (T) -> String):
}
}
fun FirResolveBench.TotalStatistics.report(stream: PrintStream, header: String, errorTypeReports: Boolean = true) {
with(stream) {
if (errorTypeReports)
errorTypesReports.values.sortedByDescending { it.count }.forEach {
print("${it.count}:")
println(it.report)
}
fun FirResolveBench.TotalStatistics.reportErrors(stream: PrintStream) {
errorTypesReports.values.sortedByDescending { it.count }.forEach {
stream.print("${it.count}:")
stream.println(it.report)
}
}
fun FirResolveBench.TotalStatistics.report(stream: PrintStream, header: String) {
with(stream) {
infix fun Int.percentOf(other: Int): String {
return String.format("%.1f%%", this * 100.0 / other)
}
println()
println("---------- $header ----------")
println("========== $header ==========")
println("Unresolved (untouched) implicit types: $unresolvedTypes (${unresolvedTypes percentOf totalTypes})")
println("Resolved types: $resolvedTypes (${resolvedTypes percentOf totalTypes})")
println("Correctly resolved types: $goodTypes (${goodTypes percentOf resolvedTypes} of resolved)")