Skip to content

Commit 11c7ed4

Browse files
author
jantje
committed
Find the test templates based on the HOME var
Basically the templates were hardcoded as to my system. I hope this will be more os independent
1 parent e07a531 commit 11c7ed4

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

io.sloeber.core/src/jUnit/Shared.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.eclipse.core.runtime.CoreException;
1010
import org.eclipse.core.runtime.IPath;
1111
import org.eclipse.core.runtime.Path;
12+
import org.eclipse.core.runtime.Platform;
1213
import org.eclipse.core.runtime.jobs.IJobManager;
1314
import org.eclipse.core.runtime.jobs.Job;
1415

@@ -47,8 +48,24 @@ public static void waitForAllJobsToFinish() {
4748
}
4849

4950
public static IPath getTemplateFolder(String templateName) {
50-
Path path = new Path("C:/Users/jan/git/arduino-eclipse-plugin/io.sloeber.core/src/jUnit/templates");
51-
return path.append(templateName);
51+
52+
String gitHome = System.getenv("HOME");
53+
54+
if (Platform.getOS().equals(Platform.OS_WIN32)) {
55+
if (gitHome == null) {
56+
System.err.println("Git HOME envvar is not define. Using default value");
57+
gitHome = System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
58+
}
59+
gitHome += "/git";
60+
} else {
61+
if (gitHome == null) {
62+
System.err.println("Git HOME envvar is not define. Using default value");
63+
gitHome = "~";
64+
}
65+
gitHome += "/.git";
66+
}
67+
Path path = new Path(gitHome + "/arduino-eclipse-plugin/io.sloeber.core/src/jUnit/templates/" + templateName);
68+
return path;
5269
}
5370

5471
}

0 commit comments

Comments
 (0)