Skip to content

Commit

Permalink
Fix random failing Bug_266907 #472
Browse files Browse the repository at this point in the history
The regression test for bug 266907 randomly fails. After deleting the
.project file in the first workspace session of the test, an
asynchronously executed save operation non-deterministically restores
the .project file, which is assumed to be non-existing in the second
workspace session.

With this change, the JobManager is suspended in the according workspace
session to ensure that no asynchronous save operation restoring the
.project file is executed. This is valid and reasonable since no job
executions are required in the test and it prevents an auto-save job
from being executed.
  • Loading branch information
HeikoKlare committed Jun 23, 2023
1 parent 8f7f25e commit 65bdb41
Showing 1 changed file with 5 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.tests.resources.WorkspaceSessionTest;
import org.eclipse.core.tests.session.WorkspaceSessionTestSuite;

Expand All @@ -43,6 +44,10 @@ public static Test suite() {
}

public void test1CreateProjectAndDeleteProjectFile() throws Exception {
// Ensure that no asynchronous save job restores the .project file after
// deleting it by suspending the JobManager for this workspace session
Job.getJobManager().suspend();

final IWorkspace workspace = getWorkspace();
IProject project = workspace.getRoot().getProject(PROJECT_NAME);
project.create(getMonitor());
Expand Down

0 comments on commit 65bdb41

Please sign in to comment.