Skip to content

Commit

Permalink
Fix Tests on Mac OS
Browse files Browse the repository at this point in the history
WIP

This closes eclipse-m2e#1046
This closes eclipse-m2e#1080
  • Loading branch information
kwin committed Dec 22, 2022
1 parent b8a7fb3 commit c5e156b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
package org.eclipse.m2e.core.internal.project.registry;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintStream;
import java.nio.file.Files;
import java.util.Collections;
Expand Down Expand Up @@ -69,7 +69,10 @@ public void testImportLongBuildChain() throws Exception {
waitForJobsToComplete(monitor);
for(IProject p : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
if(p.hasNature(IMavenConstants.NATURE_ID)) {
poms.remove(p.getFile("pom.xml").getLocation().toFile());
File pomFile = p.getFile("pom.xml").getLocation().toFile();
if (!poms.remove(pomFile)) {
Assert.fail("Could not remove pom path " + pomFile + " from list of projects to be imported: " + poms);
}
}
}
Assert.assertEquals("Some poms were not imported as project", Collections.emptySet(), poms);
Expand All @@ -80,13 +83,13 @@ public void testImportLongBuildChain() throws Exception {
}
}

private Set<File> buildLinearHierarchy(int depth, File tempDirectory) throws FileNotFoundException {
private Set<File> buildLinearHierarchy(int depth, File tempDirectory) throws IOException {
Set<File> poms = new HashSet<>(depth, 1.f);
for(int i = 0; i < depth; i++ ) {
File projectDir = new File(tempDirectory, "p" + i);
projectDir.mkdirs();
File pom = new File(projectDir, "pom.xml");
poms.add(pom);
poms.add(pom.getCanonicalFile()); // on Mac OS the temp file is reachable via /var which is a symbolic link to /private/var
try (PrintStream content = new PrintStream(pom);) {
content.println("<project>");
content.println(" <modelVersion>4.0.0</modelVersion>");
Expand Down
52 changes: 28 additions & 24 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
<name>Maven Integration for Eclipse (root)</name>

<properties>
<tycho.testArgLine>-Xmx800m</tycho.testArgLine>
<tychoDefaultTestArgLine>-Xmx800m</tychoDefaultTestArgLine>
<tycho.testArgLine>${tychoDefaultTestArgLine}</tycho.testArgLine>
<tycho.surefire.timeout>900</tycho.surefire.timeout>
<tycho.surefire.useUIHarness>true</tycho.surefire.useUIHarness>
<tycho.surefire.useUIThread>true</tycho.surefire.useUIThread>
Expand Down Expand Up @@ -124,28 +125,8 @@
<version>2.1.0-SNAPSHOT</version>
</artifact>
</target>
<environments>
<environment>
<os>win32</os>
<ws>win32</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>linux</os>
<ws>gtk</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>x86_64</arch>
</environment>
<environment>
<os>macosx</os>
<ws>cocoa</ws>
<arch>aarch64</arch>
</environment>
</environments>
<!-- don't define any environments to let Tycho automatically pick the current one -->
<!-- if multiple environments would be defined here all would need to resolve even OS specific dependencies -->
</configuration>
</plugin>
</plugins>
Expand Down Expand Up @@ -226,8 +207,31 @@
</activation>
<properties>
<!-- SWT on Mac OS needs to be started on main thread -->
<tycho.testArgLine>-XstartOnFirstThread</tycho.testArgLine>
<tycho.testArgLine>-XstartOnFirstThread ${tychoDefaultTestArgLine}</tycho.testArgLine>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-surefire-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<printBundles>true</printBundles>
<dependencies combine.children="append">
<!--this dependency is needed to detect and set the default VM correctly on Mac OS,
https://github.com/eclipse-jdt/eclipse.jdt.debug/tree/master/org.eclipse.jdt.launching.macosx -->
<dependency>
<artifactId>org.eclipse.jdt.launching.macosx</artifactId>
<type>eclipse-plugin</type>
<version>0.0.0</version>
</dependency>
</dependencies>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
<profile>
<id>its</id>
Expand Down

0 comments on commit c5e156b

Please sign in to comment.