-
-
Notifications
You must be signed in to change notification settings - Fork 29
/
bb.edn
116 lines (102 loc) · 5.96 KB
/
bb.edn
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
{:paths ["script"]
:deps {io.github.borkdude/quickdoc
#_{:local/root "../../quickdoc"}
{:git/url "https://github.com/borkdude/quickdoc"
:git/sha "32e726cd6d785d00e49d4e614a05f7436d3831c0"}
org.clj-commons/digest {:mvn/version "1.4.100"}}
:tasks
{:requires ([babashka.cli :as cli]
[babashka.fs :as fs])
:init (do
(def shell-opts {:extra-env
{(if (fs/windows?) "Path" "PATH")
(str (fs/canonicalize "target/test/on-path") fs/path-separator (System/getenv "PATH"))}})
(defn parse-repl-args [args]
(let [cli-spec {:spec
{:host {:desc "Bind to host (use 0.0.0.0 to allow anyone to connect)"
:alias :h
:default "localhost"}}
:restrict true}]
(cli/parse-opts args cli-spec))))
clean {:doc "Delete build work"
:task (do
(fs/delete-tree "target")
(shell {:dir "test-native"} "bb clean"))}
dev:jvm {:doc "Start a jvm nREPL server with PATH appropriatly setup for tests"
:task (let [opts (parse-repl-args *command-line-args*)
host (:host opts)]
(shell shell-opts
"clj" "-M:clj-1.11:test:nrepl/jvm" "-h" host "-b" host))}
-bb {:doc "Internal - launched by dev:bb, test:bb"
:extra-paths ["test"]
:extra-deps {;; inherit base deps from deps.edn
babashka/process {:local/root "."}
;; repeat necessary :test deps from deps.edn
io.github.cognitect-labs/test-runner {:git/tag "v0.5.1" :git/sha "dfb30dd"}}
:requires ([cognitect.test-runner])
:task (let [target (cli/coerce (first *command-line-args*) :keyword) ;; should be either :test or :dev
args (rest *command-line-args*)]
;; flag: sub-process should reload babashka.process
(System/setProperty "babashka.process.test.reload" "true")
;; flag: force use of bb even if natively compiled version of run-exec exists
(System/setProperty "babashka.process.test.run-exec" "bb")
;; run from babashka.process sources, not built-in babaska.process
(require '[babashka.process] :reload)
(case target
:test (apply cognitect.test-runner.-main args)
:dev (let [opts (parse-repl-args args)]
(babashka.nrepl.server/start-server! opts)
(deref (promise)))))}
dev:bb {:doc "Start a bb nREPL server with PATH appropriately setup for tests"
:task (apply shell shell-opts
"bb -bb :dev" *command-line-args*)}
quickdoc {:doc "Invoke quickdoc"
:requires ([quickdoc.api :as api])
:task (api/quickdoc {:git/branch "master"
:github/repo "https://github.com/babashka/process"
:toc true
:var-links true})}
-prep-native-exec {:doc "Prep for native exec test"
:task (shell {:dir "test-native"} "bb native")}
test:native {:doc "Run exec tests with native runner (requires GraalVM compilation)."
:depends [-prep-native-exec]
:task (apply clojure shell-opts
"-M:test:clj-1.11" "--namespace" "babashka.process-exec-test" *command-line-args*)}
test:bb {:doc "Run all tests under bb"
:task (apply shell shell-opts
"bb -bb :test" *command-line-args*)}
test:jvm {:doc "Run jvm tests, optionally specify clj-version (ex. :clj-1.10 :clj-1.11(default) or :clj-all)"
:requires ([clojure.string :as str]
[clojure.edn :as edn])
:task (let [args *command-line-args*
farg (first *command-line-args*)
;; allow for missing leading colon
farg (if (and farg (str/starts-with? farg "clj-"))
(str ":" farg)
farg)
clj-version-aliases (->> "deps.edn"
slurp
edn/read-string
:aliases
keys
(map str)
(filter (fn [a] (-> a name (str/starts-with? ":clj-"))))
(into []))
[aliases args] (cond
(nil? farg) [[":clj-1.11"] []]
(= ":clj-all" farg) [clj-version-aliases (rest args)]
(and (str/starts-with? farg ":clj-")
(not (some #{farg} clj-version-aliases)))
(throw (ex-info (format "%s not recognized, valid clj- args are: %s or \":clj-all\"" farg clj-version-aliases) {}))
(some #{farg} clj-version-aliases) [[farg] (rest args)]
:else [[":clj-1.11"] args])]
(doseq [alias aliases]
(do
(println (format "-[Running jvm tests for %s]-" alias))
(apply clojure
shell-opts
(str "-M:test" alias) "--namespace" "babashka.process-test" args))))}
;; hidden CI support tasks
-ci-install-jdk {:doc "Helper to download and install jdk under ~/tools on circleci"
:requires ([circle-ci])
:task (apply circle-ci/install-jdk *command-line-args*)}}}