mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
IDEA-285661 Fix tests broken by changes in JUnit execution output
Test starts to fail after the changes 6f356e75df62e7ac54903402a588d438a0d4c438 (particularly, in `JUnit5TestExecutionListener`). GitOrigin-RevId: cfbcb5b98f5d5701ee417f9fee8b1e735fda60e2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
399b8ba853
commit
33005ecb44
@@ -214,18 +214,12 @@ abstract class CommonJavaTargetTestBase(protected val executionMode: ExecutionMo
|
||||
for (child in testrun.getChildren("suite")) {
|
||||
child.removeAttribute("duration")
|
||||
for (testChild in child.getChildren("test")) {
|
||||
testChild.removeAttribute("duration")
|
||||
|
||||
// Stacktrace for LocalJavaTargetTest differs here due to usage of AppMainV2 in ProcessProxyFactoryImpl;
|
||||
// let's mask that; AppMainV2 won't be used in production, only when running from sources
|
||||
testChild.getChildren("output").forEach {
|
||||
val content = it.getContent(0)
|
||||
assertEquals(writer.toString(), Content.CType.Text, content.cType)
|
||||
val contentText = content.value
|
||||
it.setContent(Text(contentText.substring(0, contentText.length.coerceAtMost(600))))
|
||||
}
|
||||
purifyTestNode(testChild, writer)
|
||||
}
|
||||
}
|
||||
for (testChild in testrun.getChildren("test")) {
|
||||
purifyTestNode(testChild, writer)
|
||||
}
|
||||
|
||||
val expectedText = when (executionMode) {
|
||||
ExecutionMode.DEBUG -> {
|
||||
@@ -234,12 +228,9 @@ abstract class CommonJavaTargetTestBase(protected val executionMode: ExecutionMo
|
||||
else -> {
|
||||
val element = JDOMUtil.load(expectedTestsResultExported)
|
||||
element.getChildren("suite").forEach { suite ->
|
||||
suite.getChildren("test").forEach { testElement ->
|
||||
removeContentsPartially(testElement) {
|
||||
it?.text?.contains("Debugger:") ?: false
|
||||
}
|
||||
}
|
||||
suite.getChildren("test").forEach(::removeDebuggerOutput)
|
||||
}
|
||||
element.getChildren("test").forEach(::removeDebuggerOutput)
|
||||
JDOMUtil.write(element)
|
||||
}
|
||||
}
|
||||
@@ -248,6 +239,25 @@ abstract class CommonJavaTargetTestBase(protected val executionMode: ExecutionMo
|
||||
}
|
||||
}
|
||||
|
||||
private fun purifyTestNode(testNode: Element, writer: StringWriter) {
|
||||
testNode.removeAttribute("duration")
|
||||
|
||||
// Stacktrace for LocalJavaTargetTest differs here due to usage of AppMainV2 in ProcessProxyFactoryImpl;
|
||||
// let's mask that; AppMainV2 won't be used in production, only when running from sources
|
||||
testNode.getChildren("output").forEach {
|
||||
val content = it.getContent(0)
|
||||
assertEquals(writer.toString(), Content.CType.Text, content.cType)
|
||||
val contentText = content.value
|
||||
it.setContent(Text(contentText.substring(0, contentText.length.coerceAtMost(600))))
|
||||
}
|
||||
}
|
||||
|
||||
private fun removeDebuggerOutput(testElement: Element) {
|
||||
removeContentsPartially(testElement) {
|
||||
it?.text?.contains("Debugger:") ?: false
|
||||
}
|
||||
}
|
||||
|
||||
protected fun processOutputReader(demandZeroExitCode: Boolean = true,
|
||||
filter: (ProcessEvent, Key<*>) -> Boolean): CompletableDeferred<String> {
|
||||
val textDeferred = CompletableDeferred<String>()
|
||||
|
||||
@@ -210,11 +210,11 @@ abstract class JavaTargetTestBase(executionMode: ExecutionMode) : CommonJavaTarg
|
||||
expectedTestsResultExported = "<testrun name=\"JUnit tests Run Configuration\">\n" +
|
||||
" <count name=\"total\" value=\"1\" />\n" +
|
||||
" <count name=\"failed\" value=\"1\" />\n" +
|
||||
" <suite locationUrl=\"java:suite://AlsoTest\" name=\"AlsoTest\" status=\"failed\">\n" +
|
||||
" <test locationUrl=\"java:test://AlsoTest/testShouldFail\" name=\"testShouldFail()\" metainfo=\"\" status=\"failed\">\n" +
|
||||
" <diff actual=\"5\" expected=\"4\" />\n" +
|
||||
" <output type=\"stdout\">Debugger: testShouldFail() reached</output>\n" +
|
||||
" <output type=\"stderr\">org.opentest4j.AssertionFailedError: \n" +
|
||||
" <root name=\"AlsoTest\" location=\"java:suite://AlsoTest\" />\n" +
|
||||
" <test locationUrl=\"java:test://AlsoTest/testShouldFail\" name=\"testShouldFail()\" metainfo=\"\" status=\"failed\">\n" +
|
||||
" <diff actual=\"5\" expected=\"4\" />\n" +
|
||||
" <output type=\"stdout\">Debugger: testShouldFail() reached</output>\n" +
|
||||
" <output type=\"stderr\">org.opentest4j.AssertionFailedError: \n" +
|
||||
"\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:54)\n" +
|
||||
"\tat org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:195)\n" +
|
||||
"\tat org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:152)\n" +
|
||||
@@ -223,8 +223,7 @@ abstract class JavaTargetTestBase(executionMode: ExecutionMode) : CommonJavaTarg
|
||||
"\tat AlsoTest.testShouldFail(AlsoTest.java:12)\n" +
|
||||
"\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" +
|
||||
"\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(</output>\n" +
|
||||
" </test>\n" +
|
||||
" </suite>\n" +
|
||||
" </test>\n" +
|
||||
"</testrun>")
|
||||
}
|
||||
|
||||
@@ -320,11 +319,11 @@ abstract class JavaTargetTestBase(executionMode: ExecutionMode) : CommonJavaTarg
|
||||
expectedTestsResultExported = "<testrun name=\"JUnit tests Run Configuration\">\n" +
|
||||
" <count name=\"total\" value=\"1\" />\n" +
|
||||
" <count name=\"failed\" value=\"1\" />\n" +
|
||||
" <suite locationUrl=\"java:suite://AlsoTest\" name=\"AlsoTest\" status=\"failed\">\n" +
|
||||
" <test locationUrl=\"java:test://AlsoTest/testShouldFail\" name=\"testShouldFail()\" metainfo=\"\" status=\"failed\">\n" +
|
||||
" <diff actual=\"5\" expected=\"4\" />\n" +
|
||||
" <output type=\"stdout\">Debugger: testShouldFail() reached</output>\n" +
|
||||
" <output type=\"stderr\">org.opentest4j.AssertionFailedError: \n" +
|
||||
" <root name=\"AlsoTest\" location=\"java:suite://AlsoTest\" />\n" +
|
||||
" <test locationUrl=\"java:test://AlsoTest/testShouldFail\" name=\"testShouldFail()\" metainfo=\"\" status=\"failed\">\n" +
|
||||
" <diff actual=\"5\" expected=\"4\" />\n" +
|
||||
" <output type=\"stdout\">Debugger: testShouldFail() reached</output>\n" +
|
||||
" <output type=\"stderr\">org.opentest4j.AssertionFailedError: \n" +
|
||||
"\tat org.junit.jupiter.api.AssertionUtils.fail(AssertionUtils.java:54)\n" +
|
||||
"\tat org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:195)\n" +
|
||||
"\tat org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:152)\n" +
|
||||
@@ -333,8 +332,7 @@ abstract class JavaTargetTestBase(executionMode: ExecutionMode) : CommonJavaTarg
|
||||
"\tat AlsoTest.testShouldFail(AlsoTest.java:12)\n" +
|
||||
"\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)\n" +
|
||||
"\tat java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(</output>\n" +
|
||||
" </test>\n" +
|
||||
" </suite>\n" +
|
||||
" </test>\n" +
|
||||
"</testrun>")
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user