fix tests [skip ci]

This commit is contained in:
Michiel Borkent 2021-03-17 13:48:21 +01:00
parent afed99ad1b
commit 9051d3aac7
2 changed files with 8 additions and 3 deletions

View file

@ -362,7 +362,7 @@ Use -- to separate script command line args from bb command line args.
(defn error [msg exit]
(binding [*out* *err*]
(println msg)
{:exec (fn [] exit)}))
{:exec (fn [] [nil exit])}))
(defn parse-opts [options]
(let [opts (loop [options options
@ -515,7 +515,10 @@ Use -- to separate script command line args from bb command line args.
:shell
(let [args (get task :args)]
{:exec (fn []
(p/process args {:inherit true}) p/check)})
[nil
(-> (p/process args {:inherit true})
p/check
:exit)])})
:fn
(let [var (get task :var)
var-sym (symbol var)]
@ -708,7 +711,7 @@ Use -- to separate script command line args from bb command line args.
:verbose? verbose?
:preloads preloads
:loader (:loader @cp/cp-state)}))))
exec-fn [(exec-fn) 0]
exec-fn (exec-fn)
exec-src [(sci/binding [sci/file (or @sci/file "<task: >")]
(sci/eval-string* sci-ctx exec-src))
0]

View file

@ -10,6 +10,7 @@
(defn bb-jvm [input-or-opts & args]
(reset! cp/cp-state nil)
(reset! main/env {})
(let [os (java.io.StringWriter.)
es (if-let [err (:err input-or-opts)]
err (java.io.StringWriter.))
@ -30,6 +31,7 @@
(if (string? input-or-opts)
(with-in-str input-or-opts (apply main/main args))
(apply main/main args)))]
;; (prn :err (str es))
(if (zero? res)
(str os)
(throw (ex-info (str es)