Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed a few other flaky tests #3331

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -390,11 +390,22 @@ public static void reallyWaitForAutoBuild() {
public static void waitForBuild() {
waitForBuild(null);
}

public static boolean isAutobuild(boolean enable) {

/**
* @since 2.38
*/
public static boolean isAutobuild() {
return ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
}

/**
* @deprecated use {@link #isAutobuild()} instead (the boolean parameter is unused).
*/
@Deprecated(forRemoval = true)
public static boolean isAutobuild(boolean enable) {
return isAutobuild();
}

public static boolean setAutobuild(boolean enable) {
IWorkspaceDescription description = ResourcesPlugin.getWorkspace().getDescription();
boolean oldValue = description.isAutoBuilding();
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
Loading