Skip to content
Merged
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
@@ -1,6 +1,5 @@
package org.eclipse.pde.ds.internal.annotations.tests;

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

wsJob.schedule();
wsJob.join();
IStatus result = wsJob.getResult();
if (result != null && !result.isOK()) {
throw new CoreException(result);
}
}

@Override
Expand All @@ -97,7 +102,7 @@ public void afterAll(ExtensionContext context) throws Exception {
@Override
public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
for (String projectId : PROJECTS.keySet()) {
IProject project = wsRoot.getProject("ds.annotations." + projectId);
IProject project = wsRoot.getProject(projectId);
if (project.exists()) {
project.delete(true, true, monitor);
}
Expand Down