aboutsummaryrefslogtreecommitdiff
path: root/lux-lein/src/leiningen/lux/test.clj
blob: a51a2c3bc76ee6134271f8ab5f85b4f1ac4dad2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(ns leiningen.lux.test
  (:refer-clojure :exclude [test])
  (:require [leiningen.core.classpath :as classpath]
            (leiningen.lux [utils :as &utils]
                           [packager :as &packager])))

(def missing-module-error "Please provide a test module in [:lux :test]")

(defn test [project]
  (if-let [[test-module test-definition] (get-in project [:lux :test])]
    (when (time (&utils/run-process (&utils/compile-path project test-module test-definition (concat (:test-paths project) (:source-paths project)))
                                    nil
                                    "[COMPILATION BEGAN]"
                                    "[COMPILATION ENDED]"))
      (let [java-cmd (get project :java-cmd "java")
            jvm-opts (->> (get project :jvm-opts) (interpose " ") (reduce str ""))
            output-package (str (get project :target-path &utils/default-target-dir)
                                java.io.File/separator
                                (get project :jar-name &utils/output-package))]
        (do (time (&packager/package project test-module (get project :resource-paths (list))))
          (time (&utils/run-process (str java-cmd " " jvm-opts " -jar " output-package)
                                    nil
                                    "[TESTING BEGAN]"
                                    "[TESTING ENDED]"))
          true)))
    (println missing-module-error)))