[Gradle][test] Filter out connection message from stdout

This commit is contained in:
Pavel Punegov
2022-01-28 20:29:42 +03:00
committed by Space
parent 9b55ec43e7
commit 219d5e3ecf
3 changed files with 20 additions and 3 deletions
@@ -860,7 +860,10 @@ Finished executing task ':$taskName'|
} }
} }
val actualTestResults = readAndCleanupTestResults(testReportDirs, projectDir.toPath()) val actualTestResults = readAndCleanupTestResults(testReportDirs, projectDir.toPath()) { s ->
val excl = "Invalid connection: com.apple.coresymbolicationd"
s.lines().filter { it != excl }.joinToString("\n")
}
val expectedTestResults = prettyPrintXml(resourcesRootFile.resolve(assertionFileName).readText()) val expectedTestResults = prettyPrintXml(resourcesRootFile.resolve(assertionFileName).readText())
assertEquals(expectedTestResults, actualTestResults) assertEquals(expectedTestResults, actualTestResults)
@@ -5,6 +5,8 @@
package org.jetbrains.kotlin.gradle.testbase package org.jetbrains.kotlin.gradle.testbase
import org.jdom.CDATA
import org.jdom.Content
import org.jdom.Element import org.jdom.Element
import org.jdom.input.SAXBuilder import org.jdom.input.SAXBuilder
import org.jdom.output.Format import org.jdom.output.Format
@@ -28,7 +30,11 @@ fun GradleProject.assertTestResults(expectedTestReport: Path, vararg testReportN
assertEquals(expectedTestResults, actualTestResults) assertEquals(expectedTestResults, actualTestResults)
} }
internal fun readAndCleanupTestResults(testReportDirs: List<Path>, projectPath: Path): String { internal fun readAndCleanupTestResults(
testReportDirs: List<Path>,
projectPath: Path,
cleanupStdOut: (String) -> String = { it }
): String {
val files = testReportDirs val files = testReportDirs
.flatMap { .flatMap {
it.allFilesWithExtension("xml") it.allFilesWithExtension("xml")
@@ -64,6 +70,15 @@ internal fun readAndCleanupTestResults(testReportDirs: List<Path>, projectPath:
it.value = "..." it.value = "..."
} }
} }
if (e.name == "system-out") {
val content = e.content.map {
if (it.cType == Content.CType.CDATA) {
(it as CDATA).text = cleanupStdOut(it.value)
}
it
}
e.setContent(content)
}
e.children.forEach { e.children.forEach {
cleanup(it) cleanup(it)
@@ -11,7 +11,6 @@
<system-out><![CDATA[Foo call <system-out><![CDATA[Foo call
Bar call Bar call
42 42
Invalid connection: com.apple.coresymbolicationd
]]></system-out> ]]></system-out>
<system-err><![CDATA[]]></system-err> <system-err><![CDATA[]]></system-err>
</testsuite> </testsuite>