/
load.clj
35 lines (29 loc) · 1.22 KB
/
load.clj
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
27
28
29
30
31
32
33
34
35
(ns kaocha.load
(:require [kaocha.core-ext :refer :all]
[kaocha.classpath :as classpath]
[kaocha.testable :as testable]
[clojure.java.io :as io]
[clojure.tools.namespace.find :as ctn-find]
[kaocha.output :as out]))
(def clj ctn-find/clj)
(def cljs ctn-find/cljs)
(defn- ns-match? [ns-patterns ns-sym]
(some #(re-find % (name ns-sym)) ns-patterns))
(defn find-test-nss [test-paths ns-patterns & [platform]]
(sequence (comp
(map io/file)
(map #(ctn-find/find-namespaces-in-dir % platform))
cat
(filter (partial ns-match? ns-patterns)))
test-paths))
(defn load-test-namespaces [testable ns-testable-fn]
(let [{:kaocha/keys [test-paths ns-patterns]} testable
ns-patterns (map regex ns-patterns)]
(doseq [path test-paths]
(when-not (.exists (io/file path))
(out/warn "In :test-paths, no such file or directory: " path))
(classpath/add-classpath path))
(let [ns-names (find-test-nss test-paths ns-patterns)
testables (map ns-testable-fn ns-names)]
(assoc testable :kaocha.test-plan/tests
(testable/load-testables testables)))))