wip
This commit is contained in:
parent
ff3d1e56ba
commit
200caef226
2 changed files with 16 additions and 7 deletions
|
|
@ -738,12 +738,13 @@ Use -- to separate script command line args from bb command line args.
|
||||||
(let [opts (parse-opts args)]
|
(let [opts (parse-opts args)]
|
||||||
(if-let [do-opts (:do opts)]
|
(if-let [do-opts (:do opts)]
|
||||||
(reduce (fn [prev-exit opts]
|
(reduce (fn [prev-exit opts]
|
||||||
(if (and (pos? prev-exit)
|
(if (pos? prev-exit)
|
||||||
(not= [":or-do"] opts))
|
(case opts
|
||||||
(reduced prev-exit)
|
[":or-do"] 0
|
||||||
(if (or (= [":and-do"] opts)
|
(reduced prev-exit))
|
||||||
(= [":or-do"] opts))
|
(case opts
|
||||||
0
|
[":or-do"] (reduced prev-exit) ;; short-cutting
|
||||||
|
[":and-do"] 0 ;; skipping, returning 0
|
||||||
(exec (parse-opts opts)))))
|
(exec (parse-opts opts)))))
|
||||||
0
|
0
|
||||||
do-opts)
|
do-opts)
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,15 @@
|
||||||
:args [:do :div-by-zero :and-do :sum]}}}
|
:args [:do :div-by-zero :and-do :sum]}}}
|
||||||
(is (thrown-with-msg? Exception #"Divide"
|
(is (thrown-with-msg? Exception #"Divide"
|
||||||
(bb :all)))))
|
(bb :all)))))
|
||||||
(testing ":or-do succeeding"
|
(testing ":or-do short-cutting"
|
||||||
|
(with-config {:tasks {:sum-1 {:task/type :babashka
|
||||||
|
:args ["-e" "(+ 1 2 3)"]}
|
||||||
|
:sum-2 {:task/type :babashka
|
||||||
|
:args ["-e" "(+ 4 5 6)"]}
|
||||||
|
:all {:task/type :babashka
|
||||||
|
:args [:do :sum-1 :or-do :sum-2]}}}
|
||||||
|
(is (= 6 (bb :all)))))
|
||||||
|
(testing ":or-do succeeding after failing"
|
||||||
(with-config {:tasks {:div-by-zero {:task/type :babashka
|
(with-config {:tasks {:div-by-zero {:task/type :babashka
|
||||||
:args ["-e" "(/ 1 0)"]}
|
:args ["-e" "(/ 1 0)"]}
|
||||||
:sum {:task/type :babashka
|
:sum {:task/type :babashka
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue