-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.boot
93 lines (80 loc) · 3.33 KB
/
build.boot
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
(set-env!
:resource-paths #{"src"}
:source-paths #{"test"}
:dependencies '[[adzerk/boot-cljs "2.1.4" :scope "test"]
[adzerk/boot-cljs-repl "0.3.3" :scope "test"]
[crisptrutski/boot-cljs-test "0.3.5-SNAPSHOT" :scope "test"]
[org.clojure/clojurescript "1.10.238" :scope "test"]
[doo "0.1.8" :scope "test"]
[collection-check "0.1.7" :scope "test"
:exclusions [org.clojure/clojure]]])
(require
'[adzerk.boot-cljs :refer [cljs]]
'[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
'[crisptrutski.boot-cljs-test :refer [test-cljs]])
(require '[clojure.java.shell :as shell]
'[clojure.string :as str])
(defn- current-tag []
(let [{:keys [exit out]} (shell/sh "git" "describe" "--tags")]
(when (zero? exit)
(str/trim out))))
(def +version+
(if-let [tag (current-tag)]
(cond-> (second (re-find #"v(.*)" tag))
(.contains tag "-") (str "-SNAPSHOT"))
"0.1.0-SNAPSHOT"))
(task-options!
pom {:project 'frankiesardo/linked
:version +version+
:description "Efficient ordered map and set."
:url "https://github.com/frankiesardo/linked"
:scm {:url "https://github.com/frankiesardo/linked"}
:license {"Eclipse Public License"
"http://www.eclipse.org/legal/epl-v10.html"}})
(deftask deploy []
(comp (pom) (jar) (install)
(push :gpg-sign (not (.endsWith +version+ "-SNAPSHOT")))))
(ns-unmap 'boot.user 'test)
(require '[boot.pod :as pod]
'[boot.core :as core])
(def pod-deps
'[[pjstadig/humane-test-output "0.6.0" :exclusions [org.clojure/clojure]]])
(defn init [fresh-pod]
(doto fresh-pod
(pod/with-eval-in
(require '[clojure.test :as t]
'[clojure.java.io :as io]
'[pjstadig.humane-test-output :refer [activate!]])
(activate!)
(defn test-ns* [ns]
(binding [t/*report-counters* (ref t/*initial-report-counters*)]
(let [ns-obj (the-ns ns)]
(t/do-report {:type :begin-test-ns :ns ns-obj})
(t/test-vars (vals (ns-publics ns)))
(t/do-report {:type :end-test-ns :ns ns-obj}))
@t/*report-counters*)))))
(deftask test-clj []
(let [worker-pods (pod/pod-pool (update-in (core/get-env) [:dependencies] into pod-deps) :init init)]
(core/cleanup (worker-pods :shutdown))
(core/with-pre-wrap fileset
(let [worker-pod (worker-pods :refresh)
namespaces (core/fileset-namespaces fileset)]
(if (seq namespaces)
(let [summary (pod/with-eval-in worker-pod
(doseq [ns '~namespaces] (require ns))
(let [ns-results (map test-ns* '~namespaces)]
(-> (reduce (partial merge-with +) ns-results)
(assoc :type :summary)
(doto t/do-report))))]
(when (> (apply + (map summary [:fail :error])) 0)
(throw (ex-info "Some tests failed or errored" summary))))
(println "No namespaces were tested."))
fileset))))
(deftask test []
(comp (test-clj)
(test-cljs :js-env :phantom
:exit? true)))
(deftask autotest []
(comp (watch)
(test-clj)
(test-cljs :js-env :phantom)))