Skip to content

Commit d03f4ff

Browse files
Maximilian WittmerHeikoKlare
Maximilian Wittmer
authored andcommitted
Fix Random Failing UIEditWorkingSetWizardAuto.testEditPage eclipse-platform#275
In my experiments, the test failed in roughly 2% of runs. The test didn't close all processes which potentially accessed the files it contained. This PR Makes the Job-Manager join all jobs before finally deleting the project-root. eclipse-platform#275
1 parent e987ac1 commit d03f4ff

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/UIEditWorkingSetWizardAuto.java

+41-1
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
*******************************************************************************/
1414
package org.eclipse.ui.tests.dialogs;
1515

16-
import java.util.List;
16+
import static org.eclipse.core.resources.ResourcesPlugin.getWorkspace;
1717

18+
import java.util.List;
19+
import org.eclipse.core.internal.resources.Workspace;
1820
import org.eclipse.core.resources.IWorkspace;
21+
import org.eclipse.core.resources.IWorkspaceDescription;
1922
import org.eclipse.core.resources.ResourcesPlugin;
23+
import org.eclipse.core.runtime.CoreException;
2024
import org.eclipse.core.runtime.IAdaptable;
2125
import org.eclipse.jface.wizard.IWizardPage;
2226
import org.eclipse.swt.widgets.Composite;
@@ -57,6 +61,29 @@ private IWorkingSetPage getDefaultEditPage() {
5761
return registry.getDefaultWorkingSetPage();
5862
}
5963

64+
/**
65+
* Blocks the calling thread until autobuild completes.
66+
*/
67+
private static void waitForBuild() {
68+
((Workspace) getWorkspace()).getBuildManager().waitForAutoBuild();
69+
}
70+
71+
/**
72+
* Enables or disables workspace autobuild. Waits for the build to be finished,
73+
* even if the autobuild value did not change and a previous build is still
74+
* running.
75+
*/
76+
private static void setAutoBuilding(boolean enabled) throws CoreException {
77+
IWorkspace workspace = getWorkspace();
78+
if (workspace.isAutoBuilding() != enabled) {
79+
IWorkspaceDescription description = workspace.getDescription();
80+
description.setAutoBuilding(enabled);
81+
workspace.setDescription(description);
82+
}
83+
waitForBuild();
84+
}
85+
86+
6087
@Test
6188
public void testEditPage() throws Throwable {
6289
IWizardPage page = getWizardDialog().getCurrentPage();
@@ -119,4 +146,17 @@ public void testEditPage() throws Throwable {
119146

120147
DialogCheck.assertDialogTexts(getWizardDialog());
121148
}
149+
150+
@Override
151+
public void doSetUp() throws Exception {
152+
super.doSetUp();
153+
setAutoBuilding(false);
154+
}
155+
156+
@Override
157+
public void doTearDown() throws Exception {
158+
super.doTearDown();
159+
ResourcesPlugin.getWorkspace().setDescription(Workspace.defaultWorkspaceDescription());
160+
}
161+
122162
}

0 commit comments

Comments
 (0)