mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-02-04 23:39:07 +07:00
do not swallow test failures, making assertions useless
GitOrigin-RevId: 0d6a62694d31afcf6713e1bff826c6e726cee882
This commit is contained in:
committed by
intellij-monorepo-bot
parent
9fb10da61b
commit
ad40b6b72e
@@ -17,7 +17,10 @@ package com.intellij.testFramework.codeInsight.hierarchy;
|
||||
|
||||
import com.intellij.codeInsight.JavaCodeInsightTestCase;
|
||||
import com.intellij.ide.hierarchy.HierarchyTreeStructure;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import com.intellij.openapi.vfs.newvfs.impl.VfsRootAccess;
|
||||
import groovy.lang.GroovyObject;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
@@ -27,6 +30,15 @@ import java.io.IOException;
|
||||
* Checks tree structure for Type Hierarchy (Ctrl+H), Call Hierarchy (Ctrl+Alt+H), Method Hierarchy (Ctrl+Shift+H).
|
||||
*/
|
||||
public abstract class HierarchyViewTestBase extends JavaCodeInsightTestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
// BundledGroovyClassFinder tries to load this jar
|
||||
String groovyJar = PathManager.getJarPathForClass(GroovyObject.class);
|
||||
if (groovyJar != null) {
|
||||
VfsRootAccess.allowRootAccess(getTestRootDisposable(), groovyJar);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract String getBasePath();
|
||||
|
||||
|
||||
@@ -49,8 +49,9 @@ public final class HierarchyViewTestFixture {
|
||||
private static void doHierarchyTest(@NotNull HierarchyTreeStructure treeStructure,
|
||||
@NotNull String expectedStructure,
|
||||
@Nullable File expectedFile) {
|
||||
Element element;
|
||||
try {
|
||||
checkHierarchyTreeStructure(treeStructure, JDOMUtil.load(expectedStructure));
|
||||
element = JDOMUtil.load(expectedStructure);
|
||||
}
|
||||
catch (Throwable e) {
|
||||
String actual = dump(treeStructure, null, 0);
|
||||
@@ -59,9 +60,9 @@ public final class HierarchyViewTestFixture {
|
||||
expectedStructure, actual,
|
||||
expectedFile == null ? null : expectedFile.getAbsolutePath());
|
||||
}
|
||||
//noinspection CallToPrintStackTrace
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
checkHierarchyTreeStructure(treeStructure, element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -78,12 +79,12 @@ public final class HierarchyViewTestFixture {
|
||||
int level,
|
||||
@NotNull StringBuilder b) {
|
||||
if (level > 10) {
|
||||
for (int i = 0; i < level; i++) b.append(" ");
|
||||
b.append(" ".repeat(level));
|
||||
b.append("<Probably infinite part skipped>\n");
|
||||
return;
|
||||
}
|
||||
if (descriptor == null) descriptor = (HierarchyNodeDescriptor)treeStructure.getRootElement();
|
||||
for (int i = 0; i < level; i++) b.append(" ");
|
||||
b.append(" ".repeat(level));
|
||||
descriptor.update();
|
||||
b.append("<node text=\"").append(descriptor.getHighlightedText().getText()).append("\"")
|
||||
.append(treeStructure.getBaseDescriptor() == descriptor ? " base=\"true\"" : "");
|
||||
@@ -95,7 +96,7 @@ public final class HierarchyViewTestFixture {
|
||||
HierarchyNodeDescriptor d = (HierarchyNodeDescriptor)o;
|
||||
dump(treeStructure, d, level + 1, b);
|
||||
}
|
||||
for (int i = 0; i < level; i++) b.append(" ");
|
||||
b.append(" ".repeat(level));
|
||||
b.append("</node>\n");
|
||||
}
|
||||
else {
|
||||
@@ -103,8 +104,7 @@ public final class HierarchyViewTestFixture {
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkHierarchyTreeStructure(@NotNull HierarchyTreeStructure treeStructure,
|
||||
@Nullable Element rootElement) {
|
||||
private static void checkHierarchyTreeStructure(@NotNull HierarchyTreeStructure treeStructure, @Nullable Element rootElement) {
|
||||
HierarchyNodeDescriptor rootNodeDescriptor = (HierarchyNodeDescriptor)treeStructure.getRootElement();
|
||||
rootNodeDescriptor.update();
|
||||
if (rootElement == null || !NODE_ELEMENT_NAME.equals(rootElement.getName())) {
|
||||
@@ -159,7 +159,7 @@ public final class HierarchyViewTestFixture {
|
||||
|
||||
Iterator<Element> iterator = expectedChildren.iterator();
|
||||
for (Object child : children) {
|
||||
checkNodeDescriptorRecursively(treeStructure, ((HierarchyNodeDescriptor)child), iterator.next());
|
||||
checkNodeDescriptorRecursively(treeStructure, (HierarchyNodeDescriptor)child, iterator.next());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user