Fix totals
This commit is contained in:
@@ -33,6 +33,7 @@ class AllKotlinInspectionTest : DaemonAnalyzerTestCase() {
|
|||||||
companion object {
|
companion object {
|
||||||
private val rootProjectFile = File(".").absoluteFile
|
private val rootProjectFile = File(".").absoluteFile
|
||||||
private val statsFile = File("build/stats.csv").absoluteFile
|
private val statsFile = File("build/stats.csv").absoluteFile
|
||||||
|
private inline val Long.nsToMs get() = (this / 1e6.toLong())
|
||||||
}
|
}
|
||||||
|
|
||||||
private val tmp by lazy { createTempDirectory() }
|
private val tmp by lazy { createTempDirectory() }
|
||||||
@@ -82,19 +83,19 @@ class AllKotlinInspectionTest : DaemonAnalyzerTestCase() {
|
|||||||
|
|
||||||
val errors = mutableListOf<Throwable>()
|
val errors = mutableListOf<Throwable>()
|
||||||
|
|
||||||
for (it in profileTools) {
|
for (profileTool in profileTools) {
|
||||||
val localInspectionTool = it.tool.tool as? LocalInspectionTool ?: continue
|
val localInspectionTool = profileTool.tool.tool as? LocalInspectionTool ?: continue
|
||||||
if (it.tool.language !in setOf(null, "kotlin", "UAST")) continue
|
if (profileTool.tool.language !in setOf(null, "kotlin", "UAST")) continue
|
||||||
val result = measureNanoTime {
|
val result = measureNanoTime {
|
||||||
try {
|
try {
|
||||||
localInspectionTool.analyze(psiFile)
|
localInspectionTool.analyze(psiFile)
|
||||||
} catch (t: Throwable) {
|
} catch (t: Throwable) {
|
||||||
val myEx = ExceptionWhileInspection(it.tool.id, t)
|
val myEx = ExceptionWhileInspection(profileTool.tool.id, t)
|
||||||
myEx.printStackTrace()
|
myEx.printStackTrace()
|
||||||
errors += myEx
|
errors += myEx
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
results[it.tool.id] = result
|
results[profileTool.tool.id] = result
|
||||||
totalNs += result
|
totalNs += result
|
||||||
if (errors.isNotEmpty()) break
|
if (errors.isNotEmpty()) break
|
||||||
}
|
}
|
||||||
@@ -130,12 +131,12 @@ class AllKotlinInspectionTest : DaemonAnalyzerTestCase() {
|
|||||||
val (time, errors) = block()
|
val (time, errors) = block()
|
||||||
if (errors.isNotEmpty()) {
|
if (errors.isNotEmpty()) {
|
||||||
val detailsWriter = StringWriter()
|
val detailsWriter = StringWriter()
|
||||||
val errorDetailsPrintWriter = PrintWriter(detailsWriter)
|
PrintWriter(detailsWriter).use { errorDetailsPrintWriter ->
|
||||||
errors.forEach {
|
errors.forEach {
|
||||||
it.printStackTrace(errorDetailsPrintWriter)
|
it.printStackTrace(errorDetailsPrintWriter)
|
||||||
errorDetailsPrintWriter.println()
|
errorDetailsPrintWriter.println()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
errorDetailsPrintWriter.close()
|
|
||||||
val details = detailsWriter.toString()
|
val details = detailsWriter.toString()
|
||||||
println("##teamcity[testFailed name='$name' message='Exceptions reported' details='${details.tcEscape()}']")
|
println("##teamcity[testFailed name='$name' message='Exceptions reported' details='${details.tcEscape()}']")
|
||||||
}
|
}
|
||||||
@@ -162,12 +163,14 @@ class AllKotlinInspectionTest : DaemonAnalyzerTestCase() {
|
|||||||
statsOutput.appendln("File, InspectionID, Time")
|
statsOutput.appendln("File, InspectionID, Time")
|
||||||
|
|
||||||
fun appendInspectionResult(file: String, id: String, nanoTime: Long) {
|
fun appendInspectionResult(file: String, id: String, nanoTime: Long) {
|
||||||
|
totals.merge(id, nanoTime) { a, b -> a + b }
|
||||||
|
|
||||||
statsOutput.appendln(buildString {
|
statsOutput.appendln(buildString {
|
||||||
append(file)
|
append(file)
|
||||||
append(", ")
|
append(", ")
|
||||||
append(id)
|
append(id)
|
||||||
append(", ")
|
append(", ")
|
||||||
append((nanoTime * 1e-6).toLong())
|
append(nanoTime.nsToMs)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,7 +184,7 @@ class AllKotlinInspectionTest : DaemonAnalyzerTestCase() {
|
|||||||
result.perInspection.forEach { (k, v) ->
|
result.perInspection.forEach { (k, v) ->
|
||||||
appendInspectionResult(filePath, k, v)
|
appendInspectionResult(filePath, k, v)
|
||||||
}
|
}
|
||||||
(result.totalNs * 1e-6).toLong() to result.errors
|
result.totalNs.nsToMs to result.errors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,7 +196,7 @@ class AllKotlinInspectionTest : DaemonAnalyzerTestCase() {
|
|||||||
tcSuite("Total") {
|
tcSuite("Total") {
|
||||||
totals.forEach { (k, v) ->
|
totals.forEach { (k, v) ->
|
||||||
tcTest(k) {
|
tcTest(k) {
|
||||||
(v * 1e-6).toLong() to emptyList()
|
v.nsToMs to emptyList()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user