diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index de8312fe..537dbc25 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -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` diff --git a/test/babashka/test_utils.clj b/test/babashka/test_utils.clj index 720765bc..7badd6cc 100644 --- a/test/babashka/test_utils.clj +++ b/test/babashka/test_utils.clj @@ -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)]