Update test to use new test xml output format.

This format was slightly changed starting Gradle 6.6. Adapted
tests to use new expected output when current Gradle runner is greater
then 6.5.
This commit is contained in:
Yahor Berdnikau
2021-02-05 13:28:35 +01:00
parent 6d2465d00c
commit 6c0ee2f9ea
11 changed files with 136 additions and 20 deletions
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.gradle
import com.google.gson.Gson import com.google.gson.Gson
import org.gradle.api.logging.LogLevel import org.gradle.api.logging.LogLevel
import org.gradle.api.logging.configuration.WarningMode import org.gradle.api.logging.configuration.WarningMode
import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType
import org.jetbrains.kotlin.gradle.targets.js.ir.KLIB_TYPE import org.jetbrains.kotlin.gradle.targets.js.ir.KLIB_TYPE
import org.jetbrains.kotlin.gradle.targets.js.npm.* import org.jetbrains.kotlin.gradle.targets.js.npm.*
@@ -541,7 +542,13 @@ abstract class AbstractKotlin2JsGradlePluginIT(val irBackend: Boolean) : BaseGra
assertFileExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js") assertFileExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js")
assertFileExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js.map") assertFileExists("build/js/node_modules/kotlin-js-plugin-test/kotlin/kotlin-js-plugin-test.js.map")
assertTestResults("testProject/kotlin-js-plugin-project/tests.xml", "nodeTest") // Gradle 6.6+ slightly changed format of xml test results
val testGradleVersion = GradleVersion.version(project.chooseWrapperVersionOrFinishTest())
if (testGradleVersion < GradleVersion.version("6.6")) {
assertTestResults("testProject/kotlin-js-plugin-project/tests_pre6.6.xml", "nodeTest")
} else {
assertTestResults("testProject/kotlin-js-plugin-project/tests.xml", "nodeTest")
}
} }
} }
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.gradle
import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.checkNativeCommandLineArguments import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.checkNativeCommandLineArguments
import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.containsSequentially import org.jetbrains.kotlin.gradle.native.GeneralNativeIT.Companion.containsSequentially
import org.gradle.api.logging.configuration.WarningMode import org.gradle.api.logging.configuration.WarningMode
import org.gradle.util.GradleVersion
import org.jetbrains.kotlin.gradle.native.MPPNativeTargets import org.jetbrains.kotlin.gradle.native.MPPNativeTargets
import org.jetbrains.kotlin.gradle.native.configureMemoryInGradleProperties import org.jetbrains.kotlin.gradle.native.configureMemoryInGradleProperties
import org.jetbrains.kotlin.gradle.native.transformNativeTestProject import org.jetbrains.kotlin.gradle.native.transformNativeTestProject
@@ -672,8 +673,18 @@ class NewMultiplatformIT : BaseGradleIT() {
expectedKotlinOutputFiles.forEach { assertFileExists(it) } expectedKotlinOutputFiles.forEach { assertFileExists(it) }
// Gradle 6.6+ slightly changed format of xml test results
// If, in the test project, preset name was updated,
// update accordingly test result output for Gradle 6.6+
val testGradleVersion = chooseWrapperVersionOrFinishTest()
val expectedTestResults = if (GradleVersion.version(testGradleVersion) < GradleVersion.version("6.6")) {
"testProject/new-mpp-lib-with-tests/TEST-all-pre6.6.xml"
} else {
"testProject/new-mpp-lib-with-tests/TEST-all.xml"
}
assertTestResults( assertTestResults(
"testProject/new-mpp-lib-with-tests/TEST-all.xml", expectedTestResults,
"jsNodeTest", "jsNodeTest",
"test", // jvmTest "test", // jvmTest
"${nativeHostTargetName}Test" "${nativeHostTargetName}Test"
@@ -6,9 +6,11 @@
package org.jetbrains.kotlin.gradle.native package org.jetbrains.kotlin.gradle.native
import com.intellij.testFramework.TestDataFile import com.intellij.testFramework.TestDataFile
import org.gradle.util.GradleVersion
import org.jdom.input.SAXBuilder import org.jdom.input.SAXBuilder
import org.jetbrains.kotlin.gradle.BaseGradleIT import org.jetbrains.kotlin.gradle.BaseGradleIT
import org.jetbrains.kotlin.gradle.GradleVersionRequired import org.jetbrains.kotlin.gradle.GradleVersionRequired
import org.jetbrains.kotlin.gradle.chooseWrapperVersionOrFinishTest
import org.jetbrains.kotlin.gradle.internals.DISABLED_NATIVE_TARGETS_REPORTER_DISABLE_WARNING_PROPERTY_NAME import org.jetbrains.kotlin.gradle.internals.DISABLED_NATIVE_TARGETS_REPORTER_DISABLE_WARNING_PROPERTY_NAME
import org.jetbrains.kotlin.gradle.internals.DISABLED_NATIVE_TARGETS_REPORTER_WARNING_PREFIX import org.jetbrains.kotlin.gradle.internals.DISABLED_NATIVE_TARGETS_REPORTER_WARNING_PREFIX
import org.jetbrains.kotlin.gradle.internals.NO_NATIVE_STDLIB_PROPERTY_WARNING import org.jetbrains.kotlin.gradle.internals.NO_NATIVE_STDLIB_PROPERTY_WARNING
@@ -678,14 +680,29 @@ class GeneralNativeIT : BaseGradleIT() {
} }
} }
assertTestResults("testProject/native-tests/TEST-TestKt.xml", hostTestTask) // Gradle 6.6+ slightly changed format of xml test results
// If, in the test project, preset name was updated,
// update accordingly test result output for Gradle6.6+
val testGradleVersion = project.chooseWrapperVersionOrFinishTest()
val expectedTestResults = if (GradleVersion.version(testGradleVersion) < GradleVersion.version("6.6")) {
listOf(
"testProject/native-tests/TEST-TestKt_pre6.6.xml",
"testProject/native-tests/TEST-TestKt-IOSsim_pre6.6.xml",
)
} else {
listOf(
"testProject/native-tests/TEST-TestKt.xml",
"testProject/native-tests/TEST-TestKt-IOSsim.xml",
)
}
assertTestResults(expectedTestResults.first(), hostTestTask)
// K/N doesn't report line numbers correctly on Linux (see KT-35408). // K/N doesn't report line numbers correctly on Linux (see KT-35408).
// TODO: Uncomment when this is fixed. // TODO: Uncomment when this is fixed.
//assertStacktrace(hostTestTask) //assertStacktrace(hostTestTask)
if (hostIsMac) { if (hostIsMac) {
assertTestResultsAnyOf( assertTestResultsAnyOf(
"testProject/native-tests/TEST-TestKt.xml", expectedTestResults[0],
"testProject/native-tests/TEST-TestKt-IOSsim.xml", expectedTestResults[1],
"iosTest" "iosTest"
) )
assertStacktrace("iosTest") assertStacktrace("iosTest")
@@ -1,10 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<results> <results>
<testsuite name="com.example.MainTest" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="..."> <testsuite name="com.example.MainTest" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties /> <properties />
<testcase name="testHello" classname="com.example.MainTest" time="..." /> <testcase name="testHello[node]" classname="com.example.MainTest" time="..." />
<system-out /> <system-out />
<system-err /> <system-err />
</testsuite> </testsuite>
</results> </results>
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<testsuite name="com.example.MainTest" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties />
<testcase name="testHello" classname="com.example.MainTest" time="..." />
<system-out />
<system-err />
</testsuite>
</results>
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<testsuite name="org.foo.test.TestKt" tests="3" skipped="0" failures="1" errors="0" timestamp="..." hostname="..." time="...">
<properties/>
<testcase name="fooTest[ios]" classname="org.foo.test.TestKt" time="..."/>
<testcase name="barTest[ios]" classname="org.foo.test.TestKt" time="..."/>
<testcase name="fail[ios" classname="org.foo.test.TestKt" time="...">
<failure message="..." type="kotlin.IllegalStateException">...</failure>
</testcase>
<system-out><![CDATA[Foo call
Bar call
Invalid connection: com.apple.coresymbolicationd
]]></system-out>
<system-err><![CDATA[]]></system-err>
</testsuite>
</results>
@@ -2,9 +2,9 @@
<results> <results>
<testsuite name="org.foo.test.TestKt" tests="3" skipped="0" failures="1" errors="0" timestamp="..." hostname="..." time="..."> <testsuite name="org.foo.test.TestKt" tests="3" skipped="0" failures="1" errors="0" timestamp="..." hostname="..." time="...">
<properties/> <properties/>
<testcase name="fooTest" classname="org.foo.test.TestKt" time="..."/> <testcase name="fooTest[host]" classname="org.foo.test.TestKt" time="..."/>
<testcase name="barTest" classname="org.foo.test.TestKt" time="..."/> <testcase name="barTest[host]" classname="org.foo.test.TestKt" time="..."/>
<testcase name="fail" classname="org.foo.test.TestKt" time="..."> <testcase name="fail[host]" classname="org.foo.test.TestKt" time="...">
<failure message="..." type="kotlin.IllegalStateException">...</failure> <failure message="..." type="kotlin.IllegalStateException">...</failure>
</testcase> </testcase>
<system-out><![CDATA[Foo call <system-out><![CDATA[Foo call
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<testsuite name="org.foo.test.TestKt" tests="3" skipped="0" failures="1" errors="0" timestamp="..." hostname="..." time="...">
<properties/>
<testcase name="fooTest" classname="org.foo.test.TestKt" time="..."/>
<testcase name="barTest" classname="org.foo.test.TestKt" time="..."/>
<testcase name="fail" classname="org.foo.test.TestKt" time="...">
<failure message="..." type="kotlin.IllegalStateException">...</failure>
</testcase>
<system-out><![CDATA[Foo call
Bar call]]></system-out>
<system-err/>
</testsuite>
</results>
@@ -0,0 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?>
<results>
<testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties />
<testcase name="testId" classname="com.example.lib.TestCommonCode" time="..." />
<testcase name="testExpectedFun" classname="com.example.lib.TestCommonCode" time="..." />
<system-out />
<system-err />
</testsuite>
<testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties />
<testcase name="testId" classname="com.example.lib.TestCommonCode" time="..." />
<testcase name="testExpectedFun" classname="com.example.lib.TestCommonCode" time="..." />
<system-out><![CDATA[1]]></system-out>
<system-err />
</testsuite>
<testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties />
<testcase name="testId" classname="com.example.lib.TestCommonCode" time="..." />
<testcase name="testExpectedFun" classname="com.example.lib.TestCommonCode" time="..." />
<system-out />
<system-err />
</testsuite>
<testsuite name="com.example.lib.TestJava" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties />
<testcase name="testJava" classname="com.example.lib.TestJava" time="..." />
<system-out />
<system-err />
</testsuite>
<testsuite name="com.example.lib.TestJs" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties />
<testcase name="testJsSpecificCode" classname="com.example.lib.TestJs" time="..." />
<system-out />
<system-err />
</testsuite>
<testsuite name="com.example.lib.TestWithJava" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties />
<testcase name="testJavaClass" classname="com.example.lib.TestWithJava" time="..." />
<system-out />
<system-err />
</testsuite>
</results>
@@ -2,8 +2,8 @@
<results> <results>
<testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="..."> <testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties /> <properties />
<testcase name="testId" classname="com.example.lib.TestCommonCode" time="..." /> <testcase name="testId[js, node]" classname="com.example.lib.TestCommonCode" time="..." />
<testcase name="testExpectedFun" classname="com.example.lib.TestCommonCode" time="..." /> <testcase name="testExpectedFun[js, node]" classname="com.example.lib.TestCommonCode" time="..." />
<system-out /> <system-out />
<system-err /> <system-err />
</testsuite> </testsuite>
@@ -16,8 +16,8 @@
</testsuite> </testsuite>
<testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="..."> <testsuite name="com.example.lib.TestCommonCode" tests="2" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties /> <properties />
<testcase name="testId" classname="com.example.lib.TestCommonCode" time="..." /> <testcase name="testId[linux64]" classname="com.example.lib.TestCommonCode" time="..." />
<testcase name="testExpectedFun" classname="com.example.lib.TestCommonCode" time="..." /> <testcase name="testExpectedFun[linux64]" classname="com.example.lib.TestCommonCode" time="..." />
<system-out /> <system-out />
<system-err /> <system-err />
</testsuite> </testsuite>
@@ -29,7 +29,7 @@
</testsuite> </testsuite>
<testsuite name="com.example.lib.TestJs" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="..."> <testsuite name="com.example.lib.TestJs" tests="1" skipped="0" failures="0" errors="0" timestamp="..." hostname="..." time="...">
<properties /> <properties />
<testcase name="testJsSpecificCode" classname="com.example.lib.TestJs" time="..." /> <testcase name="testJsSpecificCode[js, node]" classname="com.example.lib.TestJs" time="..." />
<system-out /> <system-out />
<system-err /> <system-err />
</testsuite> </testsuite>