Skip to content

Commit

Permalink
Merge pull request #3331 from LorenzoBettini/lb_3319_experiments
Browse files Browse the repository at this point in the history
Fixed a few other flaky tests
  • Loading branch information
LorenzoBettini authored Feb 1, 2025
2 parents 2fb90d5 + ec36fa2 commit 2e919f4
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import java.util.concurrent.atomic.AtomicBoolean;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.xtend.ide.tests.AbstractXtendUITestCase;
import org.eclipse.xtend.ide.tests.WorkbenchTestHelper;
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil;
Expand All @@ -31,15 +32,6 @@ public class QuickDebugSourceInstallingCompilationParticipantTest extends Abstra

@Test
public void testIfThereIsAnyStatum() throws Exception {
// ensure JDT is fully functional and its participants registered
workbenchTestHelper.createFile("hello/Hello.java", """
package hello;
public class Hello {
}
""");
IResourcesSetupUtil.waitForBuild();

final IFile source = workbenchTestHelper.createFile("somePackage/Outer.xtend", """
package somePackage
Expand All @@ -51,11 +43,11 @@ def dosomething() {
}
}
""");
IResourcesSetupUtil.waitForBuild();

// ensure also JDT builder finished its jobs
IResourcesSetupUtil.waitForBuild(
new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("ANOTHER BUILD"));
new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("XTEND BUILD"));

source.getProject().refreshLocal(IResource.DEPTH_INFINITE,
new IResourcesSetupUtil.ConsoleLoggingProgressMonitor("REFRESH"));

final IFile clazz = source.getProject().getFile("bin/somePackage/Outer.class");
assertTrue("bytecode not found", clazz.exists());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class XtendHoverInEditorTest extends AbstractXtendUITestCase {
waitForBuild(null)

val editor = openEditor(fileBar)
editor.waitForReconciler
val loggings = LoggingTester.captureLogging(Level.ERROR, AbstractBatchTypeResolver) [
val info = (hoverer as ITextHoverExtension2).getHoverInfo2(editor.internalSourceViewer as ITextViewer, new Region(19,1)) as XtextBrowserInformationControlInput
assertTrue(info.html,info.html.contains("Hello Foo"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void testHoverOfReferencedElementWithAnnotation() {
final IFile fileBar = this.helper.createFile("Bar.xtend", contentBar);
this._syncUtil.waitForBuild(null);
final XtextEditor editor = this.helper.openEditor(fileBar);
this._syncUtil.waitForReconciler(editor);
final Runnable _function = () -> {
ISourceViewer _internalSourceViewer = editor.getInternalSourceViewer();
Region _region = new Region(19, 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,28 @@
import org.eclipse.jdt.internal.core.JavaModelManager;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.ui.texteditor.MarkerUtilities;
import org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

/**
* @author dhuebner - Initial contribution and API
*/
public class InternalBuilderTest {

private boolean wasAutoBuild;

@Before
public void saveAutoBuild() {
wasAutoBuild = IResourcesSetupUtil.isAutobuild();
}

@After
public void resetAutoBuild() {
setAutoBuild(wasAutoBuild);
}

@Test
public void test() throws CoreException, FileNotFoundException {

Expand Down Expand Up @@ -163,7 +178,7 @@ public static void waitForAutoBuild() {
} while (wasInterrupted);
}

public static void setAutoBuild(boolean b) {
private static void setAutoBuild(boolean b) {
System.out.println("Setting auto-build to " + b);

IWorkspace workspace = ResourcesPlugin.getWorkspace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ private void assertAndApplySingleResolution(XtextEditor xtextEditor, String issu

private void assertAndApplyAllResolutions(XtextEditor xtextEditor, String issueCode, int issueDataCount, int issueCount,
String resolutionLabel) throws CoreException {
InternalBuilderTest.setAutoBuild(true);
if (xtextEditor.isDirty()) {
xtextEditor.doSave(new NullProgressMonitor());
}
Expand Down

0 comments on commit 2e919f4

Please sign in to comment.