Skip to content

Commit

Permalink
Support multi-environment install for p2installed test runtime
Browse files Browse the repository at this point in the history
For some rare cases it is usefull to provision an install with multiple
environments. This adds a new option installAllEnvironments to support
this.
  • Loading branch information
laeubi committed Nov 25, 2023
1 parent 3f41779 commit 2b82b64
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ public abstract class AbstractEclipseTestMojo extends AbstractTestMojo {
@Parameter
private BundleStartLevel defaultStartLevel;

/**
* If {@link #testRuntime} is <code>p2Installed</code> installs all configured environments
*/
@Parameter
private boolean installAllEnvironments;

/**
* Flaky tests will re-run until they pass or the number of reruns has been exhausted. See
* surefire documentation for details.
Expand Down Expand Up @@ -641,9 +647,24 @@ private EquinoxInstallation createProvisionedInstallation() throws MojoExecution
installationBuilder.setWorkingDir(workingDir);
installationBuilder.setDestination(work);
List<TargetEnvironment> list = getTestTargetEnvironments();
TargetEnvironment env = list.get(0);
getLog().info("Provisioning with environment " + env + "...");
return installationBuilder.install(env);
TargetEnvironment testEnvironment = list.get(0);
if (installAllEnvironments) {
TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(project);
List<TargetEnvironment> targetEnvironments = configuration.getEnvironments();
EquinoxInstallation installation = null;
for (TargetEnvironment targetEnvironment : targetEnvironments) {
getLog().info("Provisioning with environment " + targetEnvironment + "...");
installationBuilder.setProfileName(targetEnvironment.toString());
EquinoxInstallation current = installationBuilder.install(targetEnvironment);
if (targetEnvironment == testEnvironment) {
installation = current;
}
}
return installation;
} else {
getLog().info("Provisioning with environment " + testEnvironment + "...");
return installationBuilder.install(testEnvironment);
}
} catch (Exception ex) {
throw new MojoExecutionException(ex.getMessage(), ex);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,29 @@ private void executeDirector(TargetEnvironment env) throws MojoFailureException
}

private File getFinalDestination(TargetEnvironment env) {
if (PlatformPropertiesUtils.OS_MACOSX.equals(env.getOs())) {
if (!effectiveDestination.getName().endsWith(".app")) {
return new File(effectiveDestination, "Eclipse.app/Contents/Eclipse/");
}
if (PlatformPropertiesUtils.OS_MACOSX.equals(env.getOs()) && !hasRequiredMacLayout(effectiveDestination)) {
return new File(effectiveDestination, "Eclipse.app/Contents/Eclipse/");
}
return effectiveDestination;
}

private static boolean hasRequiredMacLayout(File folder) {
//TODO if we do not have this exact layout then director fails with:
//The framework persistent data location (/work/MacOS/configuration) is not the same as the framework configuration location /work/Contents/Eclipse/configuration)
//maybe we can simply configure the "persistent data location" to point to the expected one?
//or the "configuration location" must be configured and look like /work/Contents/<work>/configuration ?
//the actual values seem even depend on if this is an empty folder where one installs or an existing one
//e.g. if one installs multiple env Equinox finds the launcher and then set the location different...
if ("Eclipse".equals(folder.getName())) {
File folder2 = folder.getParentFile();
if (folder2 != null && "Contents".equals(folder2.getName())) {
File parent = folder2.getParentFile();
return parent != null && parent.getName().endsWith(".app");
}
}
return false;
}

private void validate() {
assertNotNull(workingDir, "workingDir");
assertNotNull(effectiveDestination, "destination");
Expand Down

0 comments on commit 2b82b64

Please sign in to comment.