diff truffle/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java @ 22059:cc84642d989f

Enable SLTestRunner to find tests from jar file
author Tom Rodriguez <tom.rodriguez@oracle.com>
date Tue, 04 Aug 2015 22:50:40 -0700
parents 19821eafc02c
children 503529c65456
line wrap: on
line diff
--- a/truffle/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java	Tue Aug 04 17:03:27 2015 +0200
+++ b/truffle/com.oracle.truffle.sl.test/src/com/oracle/truffle/sl/test/SLTestRunner.java	Tue Aug 04 22:50:40 2015 -0700
@@ -165,17 +165,26 @@
     public static Path getRootViaResourceURL(final Class<?> c, String[] paths) {
         URL url = c.getResource(c.getSimpleName() + ".class");
         if (url != null) {
+            char sep = File.separatorChar;
             String externalForm = url.toExternalForm();
-            if (externalForm.startsWith("file:")) {
-                char sep = File.separatorChar;
-                String suffix = sep + "bin" + sep + c.getName().replace('.', sep) + ".class";
-                if (externalForm.endsWith(suffix)) {
-                    String base = externalForm.substring("file:".length(), externalForm.length() - suffix.length());
-                    for (String path : paths) {
-                        String candidate = base + sep + path;
-                        if (new File(candidate).exists()) {
-                            return FileSystems.getDefault().getPath(candidate);
-                        }
+            String classPart = sep + c.getName().replace('.', sep) + ".class";
+            String suffix = null;
+            String prefix = null;
+            if (externalForm.startsWith("jar:file:")) {
+                prefix = "jar:file:";
+                suffix = sep + "build/truffle-sl.jar!" + classPart;
+            } else if (externalForm.startsWith("file:")) {
+                prefix = "file:";
+                suffix = sep + "bin" + classPart;
+            } else {
+                return null;
+            }
+            if (externalForm.endsWith(suffix)) {
+                String base = externalForm.substring(prefix.length(), externalForm.length() - suffix.length());
+                for (String path : paths) {
+                    String candidate = base + sep + path;
+                    if (new File(candidate).exists()) {
+                        return FileSystems.getDefault().getPath(candidate);
                     }
                 }
             }