Gradle, Kotlin/JS: fix failing tests on Windows
This commit is contained in:
@@ -25,8 +25,11 @@ import org.jetbrains.kotlin.psi.KtPackageDirective
|
||||
import org.jetbrains.kotlin.psi.KtTreeVisitorVoid
|
||||
import java.io.File
|
||||
|
||||
fun String.trimTrailingWhitespaces(): String =
|
||||
this.split('\n').joinToString(separator = "\n") { it.trimEnd() }
|
||||
|
||||
fun String.trimTrailingWhitespacesAndAddNewlineAtEOF(): String =
|
||||
this.split('\n').map { it.trimEnd() }.joinToString(separator = "\n").let {
|
||||
this.trimTrailingWhitespaces().let {
|
||||
result -> if (result.endsWith("\n")) result else result + "\n"
|
||||
}
|
||||
|
||||
|
||||
@@ -51,12 +51,15 @@ projectTest {
|
||||
dependsOn(":kotlin-gradle-plugin:validateTaskProperties")
|
||||
dependsOn(
|
||||
":kotlin-allopen:install",
|
||||
":kotlin-allopen:plugin-marker:install",
|
||||
":kotlin-noarg:install",
|
||||
":kotlin-allopen:plugin-marker:install",
|
||||
":kotlin-sam-with-receiver:install",
|
||||
":kotlin-android-extensions:install",
|
||||
":kotlin-build-common:install",
|
||||
":kotlin-compiler-embeddable:install",
|
||||
":kotlin-gradle-plugin:install",
|
||||
":kotlin-gradle-plugin:plugin-marker:install",
|
||||
":kotlin-reflect:install",
|
||||
":kotlin-annotation-processing-gradle:install",
|
||||
":kotlin-test:kotlin-test-jvm:install",
|
||||
|
||||
+16
-12
@@ -11,6 +11,7 @@ import org.jdom.output.XMLOutputter
|
||||
import org.jetbrains.kotlin.gradle.model.ModelContainer
|
||||
import org.jetbrains.kotlin.gradle.model.ModelFetcherBuildAction
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import org.jetbrains.kotlin.test.util.trimTrailingWhitespaces
|
||||
import org.junit.After
|
||||
import org.junit.AfterClass
|
||||
import org.junit.Assert
|
||||
@@ -611,12 +612,9 @@ abstract class BaseGradleIT {
|
||||
}
|
||||
|
||||
val actualTestResults = readAndCleanupTestResults(testReportDir, projectDir)
|
||||
val expectedTestResults = resourcesRootFile.resolve(assertionFileName).readText()
|
||||
val expectedTestResults = prettyPrintXml(resourcesRootFile.resolve(assertionFileName).readText())
|
||||
|
||||
assertEquals(
|
||||
prettyPrintXml(expectedTestResults),
|
||||
prettyPrintXml(actualTestResults)
|
||||
)
|
||||
assertEquals(expectedTestResults, actualTestResults)
|
||||
}
|
||||
|
||||
private fun readAndCleanupTestResults(testReportDir: File, projectDir: File): String {
|
||||
@@ -628,14 +626,20 @@ abstract class BaseGradleIT {
|
||||
it.name.replace(".xml", ".A.xml")
|
||||
}
|
||||
|
||||
val xmlString = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<results>\n" +
|
||||
files.joinToString("") {
|
||||
val xmlString = buildString {
|
||||
appendln("<?xml version=\"1.0\" encoding=\"UTF-8\"?>")
|
||||
appendln("<results>")
|
||||
files.forEach {
|
||||
appendln(
|
||||
it.readText()
|
||||
.replace(projectDir.absolutePath, "/\$PROJECT_DIR$")
|
||||
.replace(projectDir.name, "\$PROJECT_NAME$")
|
||||
.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
|
||||
} +
|
||||
"</results>"
|
||||
.trimTrailingWhitespaces()
|
||||
.replace(projectDir.absolutePath, "/\$PROJECT_DIR$")
|
||||
.replace(projectDir.name, "\$PROJECT_NAME$")
|
||||
.replace("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n", "")
|
||||
)
|
||||
}
|
||||
appendln("</results>")
|
||||
}
|
||||
|
||||
val doc = SAXBuilder().build(xmlString.reader())
|
||||
val skipAttrs = setOf("timestamp", "hostname", "time", "message")
|
||||
|
||||
+12
-11
@@ -4,6 +4,7 @@ import org.gradle.internal.operations.OperationIdentifier
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.RecordingTestResultProcessor
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesClient
|
||||
import org.jetbrains.kotlin.gradle.internal.testing.TCServiceMessagesClientSettings
|
||||
import org.jetbrains.kotlin.test.util.trimTrailingWhitespaces
|
||||
import org.slf4j.LoggerFactory
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
@@ -22,22 +23,22 @@ open class TCServiceMessagesClientTest {
|
||||
}
|
||||
|
||||
assertEquals(
|
||||
assertion.trim(),
|
||||
results.output.toString().trim()
|
||||
assertion.trimTrailingWhitespaces().trim(),
|
||||
results.output.toString().trimTrailingWhitespaces().trim()
|
||||
)
|
||||
}
|
||||
|
||||
internal open fun createClient(results: RecordingTestResultProcessor): TCServiceMessagesClient {
|
||||
return TCServiceMessagesClient(
|
||||
results,
|
||||
TCServiceMessagesClientSettings(
|
||||
"root",
|
||||
nameOfRootSuiteToAppend,
|
||||
nameOfRootSuiteToReplace,
|
||||
nameOfLeafTestToAppend,
|
||||
skipRoots
|
||||
),
|
||||
LoggerFactory.getLogger("test")
|
||||
results,
|
||||
TCServiceMessagesClientSettings(
|
||||
"root",
|
||||
nameOfRootSuiteToAppend,
|
||||
nameOfRootSuiteToReplace,
|
||||
nameOfLeafTestToAppend,
|
||||
skipRoots
|
||||
),
|
||||
LoggerFactory.getLogger("test")
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user