Skip to content

Commit ea4a2cf

Browse files
authored
Fix DS annotation test setup reliability on macOS
Fix DS annotation test setup reliability issues - Replace unreliable File.renameTo() with Files.move() for test.project rename, which throws on failure instead of failing silently - Fix afterAll() cleanup bug: project names were incorrectly doubled ("ds.annotations." + "ds.annotations.testN" instead of just the key) - Add workspace job result status checking after join to properly propagate setup errors - Increase build iterations from 2 to 3 for more reliable annotation processor output generation on all platforms
1 parent 70dd54d commit ea4a2cf

1 file changed

Lines changed: 12 additions & 7 deletions

File tree

ds/org.eclipse.pde.ds.annotations.tests/src/org/eclipse/pde/ds/internal/annotations/tests/WorkspaceSetupExtension.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.eclipse.pde.ds.internal.annotations.tests;
22

3-
import java.io.File;
43
import java.io.IOException;
54
import java.io.InputStream;
65
import java.nio.file.Files;
@@ -55,7 +54,8 @@ public void beforeAll(ExtensionContext context) throws Exception {
5554
Job wsJob = new WorkspaceJob("Test Workspace Setup") {
5655
@Override
5756
public IStatus runInWorkspace(IProgressMonitor m) throws CoreException {
58-
SubMonitor monitor = SubMonitor.convert(m, PROJECTS.size() * 8);
57+
// Per project: create(1) + open(1) + 3*(build(2) + refresh(1)) = 11
58+
SubMonitor monitor = SubMonitor.convert(m, PROJECTS.size() * 11);
5959
// import test projects
6060
Path wsRoot = ws.getRoot().getLocation().toPath();
6161
for (Map.Entry<String, String> entry : PROJECTS.entrySet()) {
@@ -64,16 +64,17 @@ public IStatus runInWorkspace(IProgressMonitor m) throws CoreException {
6464
Path projectLocation = Files.createDirectories(wsRoot.resolve(project.getName()));
6565
copyResources(bundle, entry.getValue(), projectLocation);
6666
Files.createDirectories(projectLocation.resolve("OSGI-INF"));
67-
File projectFile = projectLocation.resolve("test.project").toFile();
68-
if (projectFile.isFile()) {
69-
projectFile.renameTo(projectLocation.resolve(".project").toFile());
67+
Path projectFile = projectLocation.resolve("test.project");
68+
if (Files.isRegularFile(projectFile)) {
69+
Files.move(projectFile, projectLocation.resolve(".project"),
70+
StandardCopyOption.REPLACE_EXISTING);
7071
}
7172
} catch (IOException e) {
7273
throw new CoreException(Status.error("Error copying test project content.", e));
7374
}
7475
project.create(monitor.split(1));
7576
project.open(monitor.split(1));
76-
for (int i = 0; i < 2; i++) { // Build twice. Sometimes the setup is unstable
77+
for (int i = 0; i < 3; i++) { // Annotation processor may need multiple builds to generate all outputs
7778
project.build(IncrementalProjectBuilder.FULL_BUILD, monitor.split(2));
7879
project.refreshLocal(IResource.DEPTH_INFINITE, monitor.split(1));
7980
}
@@ -84,6 +85,10 @@ public IStatus runInWorkspace(IProgressMonitor m) throws CoreException {
8485

8586
wsJob.schedule();
8687
wsJob.join();
88+
IStatus result = wsJob.getResult();
89+
if (result != null && !result.isOK()) {
90+
throw new CoreException(result);
91+
}
8792
}
8893

8994
@Override
@@ -97,7 +102,7 @@ public void afterAll(ExtensionContext context) throws Exception {
97102
@Override
98103
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
99104
for (String projectId : PROJECTS.keySet()) {
100-
IProject project = wsRoot.getProject("ds.annotations." + projectId);
105+
IProject project = wsRoot.getProject(projectId);
101106
if (project.exists()) {
102107
project.delete(true, true, monitor);
103108
}

0 commit comments

Comments
 (0)