Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[tycho-4.0.x] Support multi-environment install for p2installed test runtime #3092

Merged
merged 1 commit into from
Nov 25, 2023
Merged
Show file tree
Hide file tree
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
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