-
-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathbb.edn
More file actions
77 lines (69 loc) · 3.42 KB
/
bb.edn
File metadata and controls
77 lines (69 loc) · 3.42 KB
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
{:min-bb-version "0.9.161"
:deps {io.github.borkdude/quickdoc
#_{:local/root "/Users/borkdude/dev/quickdoc"}
{:git/sha "5097746c91fbd6605792e7dc817a81d20b8d691a"}}
:tasks
{:requires ([babashka.fs :as fs]
[clojure.edn :as edn]
[clojure.string :as str])
:init (do
(defn parse-clj-version []
(let [args *command-line-args*
farg (first *command-line-args*)
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 []))]
(cond
(nil? farg) [[:clj-1.12] []]
(= ":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.12"] args])))
(defn from-scratch-cwd [desc aliases args]
(let [test-cwd "target/test-cwd"
cp (str/trim (with-out-str (clojure (str "-Spath -M" (str/join aliases)))))
cp (->> (fs/split-paths cp)
(mapv (fn [p] (if (fs/relative? p)
(str (fs/file ".." ".." p))
p)))
(str/join fs/path-separator))
run-alias (last aliases)
main-opts (-> "deps.edn" slurp edn/read-string :aliases run-alias :main-opts)]
(fs/create-dirs test-cwd)
(doseq [f (fs/list-dir test-cwd)]
(fs/delete-tree f {:force true}))
(println "Running" desc "from:" test-cwd)
(apply clojure
{:dir test-cwd
:extra-env {(if (fs/windows?) "Path" "PATH") (str "on-path" fs/path-separator (System/getenv "PATH"))}}
"-Scp" cp
"-M" (into main-opts args)))))
test
{:doc "Run tests, optionally specify: clj-version as first arg (ex :clj-1.10, :clj-1.11, :clj-1.12 (default) or :clj-all) and/or cognitect test-runner cli args"
:task (let [[aliases args] (parse-clj-version)]
(doseq [alias aliases]
(do
(println (format "-[Running test for %s]-" alias))
(from-scratch-cwd "tests" [alias :test-runner] args))))}
dev
{:doc "Launch an nREPL server"
:task (from-scratch-cwd "repl" [:test-runner :repl-runner] *command-line-args*)}
quickdoc
{:doc "Invoke quickdoc"
:requires ([quickdoc.api :as api])
:task (api/quickdoc {:git/branch "master"
:github/repo "https://github.com/babashka/fs"
:toc true
:var-links true
:var-pattern :wikilinks})}}}