Task tests
This commit is contained in:
parent
1020a8c335
commit
cf55681114
2 changed files with 15 additions and 5 deletions
|
|
@ -1,5 +1,6 @@
|
|||
(ns babashka.bb-edn-test
|
||||
(:require
|
||||
[babashka.fs :as fs]
|
||||
[babashka.test-utils :as test-utils]
|
||||
[clojure.edn :as edn]
|
||||
[clojure.string :as str]
|
||||
|
|
@ -32,6 +33,16 @@
|
|||
(is (= "src"
|
||||
(bb "-cp" "src" "-e" "(babashka.classpath/get-classpath)"))))))
|
||||
|
||||
(deftest task-test
|
||||
(test-utils/with-config '{:tasks {foo (+ 1 2 3)}}
|
||||
(is (= 6 (bb "foo"))))
|
||||
(let [tmp-dir (fs/create-temp-dir)
|
||||
out (str (fs/file tmp-dir "out.txt"))]
|
||||
(test-utils/with-config {:tasks {'foo (list 'shell {:out out}
|
||||
"echo hello")}}
|
||||
(bb "foo")
|
||||
(is (= "hello\n" (slurp out))))))
|
||||
|
||||
;; TODO:
|
||||
;; Do we want to support the same parsing as the clj CLI?
|
||||
;; Or do we want `--aliases :foo:bar`
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@
|
|||
(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)
|
||||
(do
|
||||
|
|
@ -67,12 +66,12 @@
|
|||
(defn bb-native [input & args]
|
||||
(let [res (p/process (into ["./bb"] args)
|
||||
(cond-> {:in input
|
||||
:out :string
|
||||
:err :string}
|
||||
:out :string
|
||||
:err :string}
|
||||
*bb-edn-path*
|
||||
(assoc
|
||||
:env (assoc (into {} (System/getenv))
|
||||
"BABASHKA_EDN" *bb-edn-path*))))
|
||||
:extra-env (assoc (into {} (System/getenv))
|
||||
"BABASHKA_EDN" *bb-edn-path*))))
|
||||
res (deref res)
|
||||
exit (:exit res)
|
||||
error? (pos? exit)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue