Commits

Meikel Brandmeyer  committed cff1807

Add test command to Compile driver

  • Participants
  • Parent commits 04a7098

Comments (0)

Files changed (1)

File 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);
         }
     }
 }