Fix #1599: propagate run error (#1601)

This commit is contained in:
Michiel Borkent 2023-08-11 13:22:50 +02:00 committed by GitHub
parent 666ce9adc9
commit ea4ebab807
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 6 deletions

View file

@ -11,6 +11,7 @@ A preview of the next release can be installed from
- [#1592](https://github.com/babashka/babashka/issues/1592): expose `sci.core` in babashka - [#1592](https://github.com/babashka/babashka/issues/1592): expose `sci.core` in babashka
- [#1596](https://github.com/babashka/babashka/issues/1596): Fix `clojure.java.browse/browse-url` truncates URLs with multiple query parameters on Windows - [#1596](https://github.com/babashka/babashka/issues/1596): Fix `clojure.java.browse/browse-url` truncates URLs with multiple query parameters on Windows
- [#1599](https://github.com/babashka/babashka/issues/1599): propagate error from `run` when task does not exist
## 1.3.182 (2023-07-20) ## 1.3.182 (2023-07-20)

View file

@ -6,7 +6,6 @@
[babashka.impl.process :as pp] [babashka.impl.process :as pp]
[babashka.process :as p] [babashka.process :as p]
[clojure.core.async :refer [<!!]] [clojure.core.async :refer [<!!]]
[clojure.java.io :as io]
[clojure.string :as str] [clojure.string :as str]
[rewrite-clj.node :as node] [rewrite-clj.node :as node]
[rewrite-clj.parser :as parser] [rewrite-clj.parser :as parser]
@ -426,8 +425,11 @@
([task] (run task nil)) ([task] (run task nil))
([task {:keys [:parallel] ([task {:keys [:parallel]
:or {parallel (:parallel (current-task))}}] :or {parallel (:parallel (current-task))}}]
(let [[[expr]] (assemble-task task parallel)] (let [[[expr] exit-code] (assemble-task task parallel)]
(sci/eval-string* (ctx) expr)))) (if (or (nil? exit-code) (zero? exit-code))
(sci/eval-string* (ctx) expr)
(throw (ex-info nil
{:babashka/exit exit-code}))))))
(defn exec (defn exec
([sym] ([sym]

View file

@ -528,3 +528,6 @@ even more stuff here\"
(deftest adjacent-bb-edn-test (deftest adjacent-bb-edn-test
(is (= {1 {:id 1}} (bb "test-resources/adjacent_bb/medley.bb"))) (is (= {1 {:id 1}} (bb "test-resources/adjacent_bb/medley.bb")))
(is (= {1 {:id 1}} (bb "-f" "test-resources/adjacent_bb/medley.bb")))) (is (= {1 {:id 1}} (bb "-f" "test-resources/adjacent_bb/medley.bb"))))
(deftest non-existing-tasks-in-run-gives-exit-code-1
(is (thrown? Exception (bb "-Sdeps" "{:tasks {foo {:task (run (quote bar))}}}" "foo"))))