Add grouping suite and improve whole kotlin tests
This commit is contained in:
Generated
+6
-1
@@ -43,11 +43,16 @@
|
|||||||
<option value="$PROJECT_DIR$/libraries/pom.xml" />
|
<option value="$PROJECT_DIR$/libraries/pom.xml" />
|
||||||
</list>
|
</list>
|
||||||
</option>
|
</option>
|
||||||
|
<option name="ignoredFiles">
|
||||||
|
<set>
|
||||||
|
<option value="$PROJECT_DIR$/libraries/tools/idl2k/pom.xml" />
|
||||||
|
</set>
|
||||||
|
</option>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectResources">
|
<component name="ProjectResources">
|
||||||
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
|
<default-html-doctype>http://www.w3.org/1999/xhtml</default-html-doctype>
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_9" default="false" project-jdk-name="9.0" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
</component>
|
</component>
|
||||||
<component name="SuppressABINotification">
|
<component name="SuppressABINotification">
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import com.intellij.codeInspection.LocalInspectionToolSession
|
|||||||
import com.intellij.codeInspection.ProblemsHolder
|
import com.intellij.codeInspection.ProblemsHolder
|
||||||
import com.intellij.codeInspection.ex.InspectionToolRegistrar
|
import com.intellij.codeInspection.ex.InspectionToolRegistrar
|
||||||
import com.intellij.codeInspection.ex.Tools
|
import com.intellij.codeInspection.ex.Tools
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager
|
import com.intellij.profile.codeInspection.ProjectInspectionProfileManager
|
||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
import org.jetbrains.kotlin.idea.refactoring.toPsiFile
|
import org.jetbrains.kotlin.idea.refactoring.toPsiFile
|
||||||
@@ -37,12 +38,12 @@ class AllKotlinInspectionTest : AllKotlinTest() {
|
|||||||
|
|
||||||
class ExceptionWhileInspection(inspectionId: String, cause: Throwable) : RuntimeException(inspectionId, cause)
|
class ExceptionWhileInspection(inspectionId: String, cause: Throwable) : RuntimeException(inspectionId, cause)
|
||||||
|
|
||||||
override fun doTest(file: File): PerFileTestResult {
|
override fun doTest(file: VirtualFile): PerFileTestResult {
|
||||||
|
|
||||||
val results = mutableMapOf<String, Long>()
|
val results = mutableMapOf<String, Long>()
|
||||||
var totalNs = 0L
|
var totalNs = 0L
|
||||||
|
|
||||||
val psiFile = file.toPsiFile() ?: run {
|
val psiFile = file.toPsiFile(project) ?: run {
|
||||||
return PerFileTestResult(results, totalNs, listOf(AssertionError("PsiFile not found for $file")))
|
return PerFileTestResult(results, totalNs, listOf(AssertionError("PsiFile not found for $file")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,10 +10,15 @@ import com.intellij.ide.impl.ProjectUtil
|
|||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.application.ex.ApplicationEx
|
import com.intellij.openapi.application.ex.ApplicationEx
|
||||||
import com.intellij.openapi.vfs.VfsUtil
|
import com.intellij.openapi.vfs.VfsUtil
|
||||||
|
import com.intellij.openapi.vfs.VirtualFile
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiElementVisitor
|
import com.intellij.psi.PsiElementVisitor
|
||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
import com.intellij.psi.PsiManager
|
import com.intellij.psi.PsiManager
|
||||||
|
import com.intellij.psi.search.FileTypeIndex
|
||||||
|
import com.intellij.psi.search.ProjectScope
|
||||||
|
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||||
|
import org.jetbrains.kotlin.idea.stubindex.KotlinSourceFilterScope
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.PrintWriter
|
import java.io.PrintWriter
|
||||||
import java.io.StringWriter
|
import java.io.StringWriter
|
||||||
@@ -37,71 +42,66 @@ abstract class AllKotlinTest : DaemonAnalyzerTestCase() {
|
|||||||
|
|
||||||
data class PerFileTestResult(val perProcess: Map<String, Long>, val totalNs: Long, val errors: List<Throwable>)
|
data class PerFileTestResult(val perProcess: Map<String, Long>, val totalNs: Long, val errors: List<Throwable>)
|
||||||
|
|
||||||
protected abstract fun doTest(file: File): PerFileTestResult
|
protected abstract fun doTest(file: VirtualFile): PerFileTestResult
|
||||||
|
|
||||||
protected fun File.toPsiFile(): PsiFile? {
|
|
||||||
val vFile = VfsUtil.findFileByIoFile(this, false) ?: return null
|
|
||||||
|
|
||||||
val psi = PsiManager.getInstance(project)
|
|
||||||
return psi.findFile(vFile)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun testWholeProjectPerformance() {
|
fun testWholeProjectPerformance() {
|
||||||
|
|
||||||
val totals = mutableMapOf<String, Long>()
|
tcSuite(this::class.simpleName ?: "Unknown") {
|
||||||
|
val totals = mutableMapOf<String, Long>()
|
||||||
|
|
||||||
val statsOutput = statsFile.bufferedWriter()
|
val statsOutput = statsFile.bufferedWriter()
|
||||||
|
|
||||||
statsOutput.appendln("File, InspectionID, Time")
|
statsOutput.appendln("File, ProcessID, 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 }
|
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)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
tcSuite("SumPerFile") {
|
tcSuite("TotalPerFile") {
|
||||||
tmp.walkTopDown().filter {
|
val scope = KotlinSourceFilterScope.projectSources(ProjectScope.getContentScope(project), project)
|
||||||
it.extension == "kt" && "testdata" !in it.path.toLowerCase() && "resources" !in it.path
|
val files = FileTypeIndex.getFiles(KotlinFileType.INSTANCE, scope)
|
||||||
}.forEach {
|
|
||||||
val filePath = it.relativeTo(tmp).path.replace(File.separatorChar, '/')
|
files.forEach {
|
||||||
tcTest(filePath) {
|
val filePath = File(it.path).relativeTo(tmp).path.replace(File.separatorChar, '/')
|
||||||
val result = doTest(it)
|
tcTest(filePath) {
|
||||||
result.perProcess.forEach { (k, v) ->
|
val result = doTest(it)
|
||||||
appendInspectionResult(filePath, k, v)
|
result.perProcess.forEach { (k, v) ->
|
||||||
|
appendInspectionResult(filePath, k, v)
|
||||||
|
}
|
||||||
|
(result.totalNs.nsToMs) to result.errors
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
statsOutput.flush()
|
||||||
|
statsOutput.close()
|
||||||
|
|
||||||
|
|
||||||
|
tcSuite("Total") {
|
||||||
|
totals.forEach { (k, v) ->
|
||||||
|
tcTest(k) {
|
||||||
|
v.nsToMs to emptyList()
|
||||||
}
|
}
|
||||||
(result.totalNs * 1e-6).toLong() to result.errors
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
statsOutput.flush()
|
|
||||||
statsOutput.close()
|
|
||||||
|
|
||||||
|
|
||||||
tcSuite("Total") {
|
|
||||||
totals.forEach { (k, v) ->
|
|
||||||
tcTest(k) {
|
|
||||||
(v * 1e-6).toLong() to emptyList()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun tcSuite(name: String, block: () -> Unit) {
|
inline fun tcSuite(name: String, block: () -> Unit) {
|
||||||
println("##teamcity[testSuiteStarted name='$name']")
|
println("##teamcity[testSuiteStarted name='$name']")
|
||||||
block()
|
block()
|
||||||
println("##teamcity[testSuiteFinished name='$name']")
|
println("##teamcity[testSuiteFinished name='$name']")
|
||||||
}
|
}
|
||||||
|
|
||||||
private inline fun tcTest(name: String, block: () -> Pair<Long, List<Throwable>>) {
|
inline fun tcTest(name: String, block: () -> Pair<Long, List<Throwable>>) {
|
||||||
println("##teamcity[testStarted name='$name' captureStandardOutput='true']")
|
println("##teamcity[testStarted name='$name' captureStandardOutput='true']")
|
||||||
val (time, errors) = block()
|
val (time, errors) = block()
|
||||||
if (errors.isNotEmpty()) {
|
if (errors.isNotEmpty()) {
|
||||||
@@ -118,7 +118,7 @@ abstract class AllKotlinTest : DaemonAnalyzerTestCase() {
|
|||||||
println("##teamcity[testFinished name='$name' duration='$time']")
|
println("##teamcity[testFinished name='$name' duration='$time']")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun String.tcEscape(): String {
|
fun String.tcEscape(): String {
|
||||||
return this
|
return this
|
||||||
.replace("|", "||")
|
.replace("|", "||")
|
||||||
.replace("[", "|[")
|
.replace("[", "|[")
|
||||||
@@ -135,4 +135,8 @@ abstract class AllKotlinTest : DaemonAnalyzerTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
val Long.nsToMs get() = this * (1e-6).toLong()
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user