Skip to content

Commit 13b913a

Browse files
author
jantje
committed
unit test code is part of build for travis
1 parent 35715fc commit 13b913a

File tree

2 files changed

+22
-46
lines changed

2 files changed

+22
-46
lines changed

io.sloeber.tests/build.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
source.. = src/
22
bin.includes = META-INF/,\
3-
.
3+
.,\
4+
src/
5+
src.includes = src/

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

Lines changed: 19 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22

33
import static org.junit.Assert.fail;
44

5+
import java.io.IOException;
6+
import java.net.URISyntaxException;
7+
import java.net.URL;
8+
59
import org.eclipse.cdt.core.model.ICModelMarker;
610
import org.eclipse.core.resources.IMarker;
711
import org.eclipse.core.resources.IProject;
812
import org.eclipse.core.resources.IResource;
913
import org.eclipse.core.runtime.CoreException;
14+
import org.eclipse.core.runtime.FileLocator;
1015
import org.eclipse.core.runtime.IPath;
1116
import org.eclipse.core.runtime.Path;
1217
import org.eclipse.core.runtime.Platform;
1318
import org.eclipse.core.runtime.jobs.IJobManager;
1419
import org.eclipse.core.runtime.jobs.Job;
20+
import org.osgi.framework.Bundle;
1521

1622
import io.sloeber.core.api.BoardsManager;
1723
import io.sloeber.core.api.Other;
@@ -70,53 +76,21 @@ public static void waitForAllJobsToFinish() {
7076

7177
public static IPath getTemplateFolder(String templateName) {
7278

73-
String gitHome = System.getenv("HOME");
79+
try {
80+
Bundle bundle = Platform.getBundle("io.sloeber.tests");
81+
Path path = new Path("src/templates/" + templateName);
82+
URL fileURL = FileLocator.find(bundle, path, null);
83+
URL resolvedFileURL=FileLocator.toFileURL(fileURL);
84+
return new Path(resolvedFileURL.toURI().getPath());
85+
} catch (URISyntaxException e) {
86+
e.printStackTrace();
87+
} catch (IOException e) {
88+
e.printStackTrace();
89+
}
7490

75-
if (Platform.getOS().equals(Platform.OS_WIN32)) {
76-
if (gitHome == null) {
77-
gitHome = System.getenv("HOMEDRIVE") + System.getenv("HOMEPATH");
78-
}
79-
} else {
80-
if (gitHome == null) {
81-
System.err.println("Git HOME envvar is not define. Using default value");
82-
gitHome = "~";
83-
}
8491

85-
}
86-
Path path = new Path(gitHome + "/git/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
87-
if (path.toFile().exists()) {
88-
return path;
89-
}
90-
path = new Path(gitHome + "/.git/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
91-
if (path.toFile().exists()) {
92-
return path;
93-
}
94-
path = new Path(gitHome + "/git/Sloeber/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
95-
if (path.toFile().exists()) {
96-
return path;
97-
}
98-
path = new Path(
99-
gitHome + "/.git/Sloeber/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
100-
if (path.toFile().exists()) {
101-
return path;
102-
}
103-
path = new Path(gitHome + "/Sloeber/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
104-
if (path.toFile().exists()) {
105-
return path;
106-
}
107-
path = new Path(
108-
gitHome + "/Sloeber/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
109-
if (path.toFile().exists()) {
110-
return path;
111-
}
112-
System.err.println("Failed to find templates in git repository. Checked following locations");
113-
System.err.println("->"+gitHome + "/git/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
114-
System.err.println("->"+gitHome + "/.git/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
115-
System.err.println("->"+gitHome + "/git/Sloeber/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
116-
System.err.println("->"+gitHome + "/.git/Sloeber/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
117-
System.err.println("->"+gitHome + "/Sloeber/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
118-
System.err.println("->"+gitHome + "/Sloeber/arduino-eclipse-plugin/io.sloeber.tests/src/templates/" + templateName);
119-
return path;
92+
System.err.println("Failed to find templates in io.sloeber.tests plugin.");
93+
return new Path(new String());
12094
}
12195

12296
}

0 commit comments

Comments
 (0)