Skip to content

Commit

Permalink
Perform atomic test cleanup of multiple projects eclipse-platform#275
Browse files Browse the repository at this point in the history
The UIEditWorkingSetWizardAuto#testEditPage randomly fails because the
project deletion during test cleanup fails. The project file of the
second project to be deleted is already locked.

To avoid that the deletion of the first project triggers some
asynchronous tasks that interfere with the deletion of the second
project, this change combines both deletions into an atomic workspace
operation. In addition, the change separates the exception handling for
both projects to see from the stack trace which of the deletions caused
the exception.

Contributes to
eclipse-platform#275
  • Loading branch information
HeikoKlare committed Jul 17, 2023
1 parent eeba07e commit 13f9f45
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.wizard.IWizard;
Expand Down Expand Up @@ -89,20 +90,20 @@ protected void checkTreeItems() {
}
}

private void deleteResources() {
try {
if (p1 != null) {
FileUtil.deleteProject(p1);
}
if (p2 != null) {
FileUtil.deleteProject(p2);
}
private void deleteResources() throws CoreException {
ResourcesPlugin.getWorkspace().run(__ -> {
deleteProject(p1);
deleteProject(p2);
}, null);
}

private void deleteProject(IProject project) {
try {
FileUtil.deleteProject(project);
} catch (CoreException e) {
TestPlugin.getDefault().getLog().log(e.getStatus());
throw createAssertionError(e);
}

}

private AssertionError createAssertionError(CoreException originalException) {
Expand Down

0 comments on commit 13f9f45

Please sign in to comment.