tests: cleanup

GitOrigin-RevId: 0ce7132701e4e5ed203022e6cfeb2ae6403f1f90
This commit is contained in:
Alexey Kudravtsev
2025-08-19 17:13:41 +02:00
committed by intellij-monorepo-bot
parent 1ac8cb7215
commit b8044d21a0
3 changed files with 22 additions and 16 deletions

View File

@@ -651,7 +651,7 @@ public class DaemonInspectionsRespondToChangesTest extends DaemonAnalyzerTestCas
@Override
public void visitIdentifier(@NotNull PsiIdentifier identifier) {
if (identifier.getText().contains("XXX")) {
holder.registerProblem(identifier.getContainingFile(),"blah", ProblemHighlightType.WARNING);
holder.registerProblem(identifier.getContainingFile(), "Blah", ProblemHighlightType.WARNING);
}
}
};
@@ -800,7 +800,7 @@ public class DaemonInspectionsRespondToChangesTest extends DaemonAnalyzerTestCas
AtomicBoolean fastToolFinished = new AtomicBoolean();
// highlights all "xxx" comments, only when there are no comments after it
String fastToolText = "blah";
String fastToolText = "Blah";
LocalInspectionTool fastTool = new MyInspectionBase() {
@Override
public void inspectionFinished(@NotNull LocalInspectionToolSession session, @NotNull ProblemsHolder problemsHolder) {

View File

@@ -145,6 +145,7 @@ public class DaemonRespondToChangesPerformanceTest extends DaemonAnalyzerTestCas
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
watcher = ApplicationManager.getApplication().executeOnPooledThread(() -> {
while (true) {
Thread.onSpinWait();
final long start1 = typingStart.get();
if (start1 == -1) break;
if (start1 == 0) {
@@ -180,7 +181,7 @@ public class DaemonRespondToChangesPerformanceTest extends DaemonAnalyzerTestCas
throw new ProcessCanceledException();
};
long hiStart = System.currentTimeMillis();
codeAnalyzer.runPasses(psiFile, editor.getDocument(), textEditor, ArrayUtilRt.EMPTY_INT_ARRAY, false, interrupt);
codeAnalyzer.runPasses(psiFile, editor.getDocument(), textEditor, ArrayUtilRt.EMPTY_INT_ARRAY, true, interrupt);
long hiEnd = System.currentTimeMillis();
DaemonProgressIndicator progress = ContainerUtil.getFirstItem(new ArrayList<>(codeAnalyzer.getUpdateProgress().values()));
String message = "Should have been interrupted: " + progress + "; Elapsed: " + (hiEnd - hiStart) + "ms";
@@ -270,7 +271,7 @@ public class DaemonRespondToChangesPerformanceTest extends DaemonAnalyzerTestCas
CodeInsightTestFixtureImpl.ensureIndexesUpToDate(project);
TextEditor textEditor = TextEditorProvider.getInstance().getTextEditor(editor);
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
codeAnalyzer.runPasses(psiFile, editor.getDocument(), textEditor, ArrayUtilRt.EMPTY_INT_ARRAY, false, interrupt);
codeAnalyzer.runPasses(psiFile, editor.getDocument(), textEditor, ArrayUtilRt.EMPTY_INT_ARRAY, true, interrupt);
throw new RuntimeException("should have been interrupted");
}

View File

@@ -401,6 +401,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
});
try {
while (true) {
Thread.onSpinWait();
try {
int[] toIgnore = new int[0];
Runnable callbackWhileWaiting = () -> {
@@ -1197,7 +1198,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
}
if (element instanceof PsiComment && element.getText().equals("//XXX")) {
while (wait.get()) {
Thread.yield();
Thread.onSpinWait();
}
holder.newAnnotation(HighlightSeverity.ERROR, SWEARING).range(element).create();
iDidIt();
@@ -1230,6 +1231,8 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
Disposer.register(getTestRootDisposable(), () -> EditorFactory.getInstance().releaseEditor(editor2));
TextEditor textEditor1 = new PsiAwareTextEditorProvider().getTextEditor(editor1);
TextEditor textEditor2 = new PsiAwareTextEditorProvider().getTextEditor(editor2);
assertNotNull(textEditor1);
assertNotNull(textEditor2);
EditorTracker.getInstance(getProject()).setActiveEditors(List.of(editor1, editor2));
// check that 'MySingletonAnnotator' is run only once for two editors for the same document
@@ -1238,9 +1241,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
MySingletonAnnotator.wait.set(true);
type("/");
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> {
MySingletonAnnotator.wait.set(false);
}, 1000, TimeUnit.MILLISECONDS);
AppExecutorUtil.getAppScheduledExecutorService().schedule(() -> MySingletonAnnotator.wait.set(false), 1000, TimeUnit.MILLISECONDS);
waitForDaemonToFinish(getProject(), editor1.getDocument());
// revert back
@@ -1344,6 +1345,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
ApplicationManager.getApplication().executeOnPooledThread(() ->
HeavyProcessLatch.INSTANCE.performOperation(HeavyProcessLatch.Type.Processing, "my own heavy op", ()-> {
while (runHeavyProcessing) {
Thread.onSpinWait();
}
})
);
@@ -1401,7 +1403,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
Future<?> future = ApplicationManager.getApplication().executeOnPooledThread(() ->
HeavyProcessLatch.INSTANCE.performOperation(HeavyProcessLatch.Type.Syncing, "my own vfs refresh", () -> {
while (runHeavyProcessing) {
Thread.yield();
Thread.onSpinWait();
}
})
);
@@ -1965,7 +1967,7 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (element instanceof PsiComment && element.getText().equals("//XXX")) {
while (wait.get()) {
Thread.yield();
Thread.onSpinWait();
}
holder.newAnnotation(HighlightSeverity.ERROR, SWEARING).range(element).create();
iDidIt();
@@ -1979,11 +1981,10 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
.filter(info -> SWEARING.equals(info.getDescription())).toList();
}
static List<HighlightInfo> syntaxHighlights(MarkupModel markupModel, String description) {
List<HighlightInfo> errors = Arrays.stream(markupModel.getAllHighlighters())
return Arrays.stream(markupModel.getAllHighlighters())
.map(highlighter -> HighlightInfo.fromRangeHighlighter(highlighter))
.filter(Objects::nonNull)
.filter(info -> description.equals(info.getDescription())).toList();
return errors;
}
}
@@ -2061,8 +2062,9 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
});
}
@SuppressWarnings("FieldMayBeStatic")
@Language(value = "JAVA", prefix="class X { void foo() {\n", suffix = "\n}\n}")
String MANY_LAMBDAS_TEXT_TO_TYPE = """
private final String MANY_LAMBDAS_TEXT_TO_TYPE = """
if (i(()->{
i(()-> {
System.out.println("vFile = ");
@@ -2080,8 +2082,9 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
}
""";
@SuppressWarnings("FieldMayBeStatic")
@Language("JAVA")
String MANY_LAMBDAS_INITIAL = """
private final String MANY_LAMBDAS_INITIAL = """
class X {
void invokeLater(Runnable r) {}
boolean i(Runnable r) { return true;}
@@ -2092,12 +2095,14 @@ public class DaemonRespondToChangesTest extends DaemonAnalyzerTestCase {
public void testDaemonDoesRestartDuringMadMonkeyTyping/*Stress*/() {
assertDaemonRestartsAndLeavesNoErrorElementsInTheEnd(MANY_LAMBDAS_INITIAL, MANY_LAMBDAS_TEXT_TO_TYPE, null);
}
@SuppressWarnings("FieldMayBeStatic")
@Language(value = "JAVA", prefix="class X { void foo() {\n", suffix = "\n}\n}")
String LONG_LINE_WITH_PARENS_TEXT_TO_TYPE = """
private final String LONG_LINE_WITH_PARENS_TEXT_TO_TYPE = """
if (highlighter != null) highlighter += " text='" + StringUtil.first(getText(), 40, true) + "'";
""";
@SuppressWarnings("FieldMayBeStatic")
@Language("JAVA")
String LONG_LINE_WITH_PARENS_INITIAL_TEXT = """
private final String LONG_LINE_WITH_PARENS_INITIAL_TEXT = """
class X {
static String getText() { return ""; }
static class StringUtil {