Meikel  Brandmeyer avatar Meikel Brandmeyer committed cff1807

Add test command to Compile driver

Comments (0)

Files changed (1)

src/main/java/clojuresque/ClojureCompile.java

     private static final String DO_COMPILE_PROP = "clojuresque.compile";
     private static final Var compile = RT.var("clojure.core", "compile");
     private static final Var require = RT.var("clojure.core", "require");
+    private static final Var apply = RT.var("clojure.core", "apply");
 
     private static Object findNamespace(Object form) {
         if (!(form instanceof ISeq))
         }
     }
 
+    public static void runTests(ISeq namespaces) throws Exception {
+        require.invoke(Symbol.intern("clojure.test"));
+        Var runtests = RT.var("clojure.test", "run-tests");
+
+        if (RT.seq(namespaces) != null) {
+            apply.invoke(require, namespaces);
+            apply.invoke(runtests, namespaces);
+        }
+    }
+
     public static void main(String[] args) throws Exception {
         ISeq argsSeq = RT.seq(args);
+
         String command = (String)argsSeq.first();
-
+        ISeq namespaces = findNamespaces(argsSeq.next());
         if (command.equals("compile")) {
-            compileFiles(findNamespaces(argsSeq.next()));
+            compileFiles(namespaces);
+        } else if (command.equals("test")) {
+            runTests(namespaces);
         }
     }
 }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.