mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-146594 Support file comparison failures in Gradle
This commit is contained in:
+14
-1
@@ -16,7 +16,10 @@
|
||||
package org.jetbrains.plugins.gradle.execution.test.runner.events;
|
||||
|
||||
import com.intellij.execution.testframework.sm.runner.SMTestProxy;
|
||||
import com.intellij.openapi.util.Condition;
|
||||
import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import org.jetbrains.plugins.gradle.execution.test.runner.GradleTestsExecutionConsoleManager;
|
||||
import org.jetbrains.plugins.gradle.util.XmlXpathHelper;
|
||||
|
||||
@@ -67,7 +70,17 @@ public class AfterTestEvent extends AbstractTestEvent {
|
||||
if ("comparison".equals(failureType)) {
|
||||
String actualText = eventXml.queryXml("/ijLog/event/test/result/actual");
|
||||
String expectedText = eventXml.queryXml("/ijLog/event/test/result/expected");
|
||||
testProxy.setTestComparisonFailed(exceptionMsg, stackTrace, actualText, expectedText);
|
||||
final Condition<String> emptyString = new Condition<String>() {
|
||||
@Override
|
||||
public boolean value(String s) {
|
||||
return StringUtil.isEmpty(s);
|
||||
}
|
||||
};
|
||||
String filePath = ObjectUtils.nullizeByCondition(
|
||||
eventXml.queryXml("/ijLog/event/test/result/filePath"), emptyString);
|
||||
String actualFilePath = ObjectUtils.nullizeByCondition(
|
||||
eventXml.queryXml("/ijLog/event/test/result/actualFilePath"), emptyString);
|
||||
testProxy.setTestComparisonFailed(exceptionMsg, stackTrace, actualText, expectedText, filePath, actualFilePath);
|
||||
}
|
||||
else {
|
||||
Couple<String> comparisonPair =
|
||||
|
||||
+29
-3
@@ -53,6 +53,11 @@ gradle.taskGraph.beforeTask { Task task ->
|
||||
|
||||
if (task instanceof Test) {
|
||||
try {
|
||||
def urls = task.classpath.files.findAll{
|
||||
it.name.equals('idea_rt.jar') || it.name.startsWith('junit')
|
||||
}.collect { it.toURI().toURL()}
|
||||
Class.forName("org.gradle.launcher.daemon.bootstrap.DaemonMain").getClassLoader().addURLs(urls)
|
||||
|
||||
logTestReportLocation(task.reports?.html?.entryPoint?.path)
|
||||
|
||||
task.beforeSuite { descriptor ->
|
||||
@@ -112,12 +117,33 @@ Object logTestEvent(def testEventType, TestDescriptorInternal testDescriptor, de
|
||||
failureType('comparison')
|
||||
xml.mkp.yieldUnescaped("<expected>$expected</expected>")
|
||||
xml.mkp.yieldUnescaped("<actual>$actual</actual>")
|
||||
} else if('junit.framework.AssertionFailedError'.equals(testResult.exception?.class?.name) ||
|
||||
return
|
||||
}
|
||||
try {
|
||||
if ('com.intellij.rt.execution.junit.FileComparisonFailure'.equals(testResult.exception?.class?.name)) {
|
||||
def expected = escapeCdata(testResult.exception.expected)
|
||||
def actual = escapeCdata(testResult.exception.actual)
|
||||
def filePath = escapeCdata(testResult.exception.filePath)
|
||||
def actualFilePath
|
||||
if (testResult.exception.hasProperty('actualFilePath')) {
|
||||
actualFilePath = escapeCdata(testResult.exception.actualFilePath)
|
||||
}
|
||||
failureType('comparison')
|
||||
xml.mkp.yieldUnescaped("<expected>$expected</expected>")
|
||||
xml.mkp.yieldUnescaped("<actual>$actual</actual>")
|
||||
xml.mkp.yieldUnescaped("<filePath>$filePath</filePath>")
|
||||
if (actualFilePath) xml.mkp.yieldUnescaped("<actualFilePath>$actualFilePath</actualFilePath>")
|
||||
return
|
||||
}
|
||||
}
|
||||
catch (ignore) {
|
||||
}
|
||||
if ('junit.framework.AssertionFailedError'.equals(testResult.exception?.class?.name) ||
|
||||
testResult.exception instanceof AssertionError) {
|
||||
failureType('assertionFailed')
|
||||
} else {
|
||||
failureType('error')
|
||||
return
|
||||
}
|
||||
failureType('error')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user