From 035167ab11905d6ef3abf55b4ced036d1dfb2f11 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Thu, 25 Mar 2021 11:23:57 +0100 Subject: [PATCH] TODO --- src/babashka/main.clj | 4 +++- test/babashka/bb_edn_test.clj | 19 ++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 7b8fe286..e92bbd6f 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -587,7 +587,9 @@ Use -- to separate script command line args from bb command line args. (let [main-arg (first args) cmd-line-args (rest args)] (parse-opts (seq (map str (concat ["--main" main-arg] cmd-line-args command-line-args))))) - (error (str "No such task: " (:task/type task)) 1)))) + :do + + (error (str "No such task: " task) 1)))) (def should-load-inits? "if true, then we should still load preloads and user.clj" diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index 0beb6f41..3e60b1a5 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -39,18 +39,19 @@ (bb :clean) (is (not (fs/exists? temp-file)))))) -#_(deftest do-task-test +(deftest sequential-task-test (testing ":and-do" (let [temp-dir (fs/create-temp-dir) temp-file (fs/create-file (fs/path temp-dir "temp-file.txt"))] - (with-config {:tasks {:clean [:shell "rm" (str temp-file)] - :sum [:babashka "-e" "(+ 1 2 3)"] - :all [:babashka :clean:sum]}} + (with-config {:tasks {:sum [:babashka "-e" "(+ 1 2 3)"] + :all [:do + [:shell "rm" (str temp-file)] + [:sum]]}} (is (fs/exists? temp-file)) (let [res (bb :all)] (is (= 6 res))) (is (not (fs/exists? temp-file))))) - (testing ":and-do shortcut" + #_(testing ":and-do shortcut" (let [temp-dir (fs/create-temp-dir) temp-file (fs/create-file (fs/path temp-dir "temp-file.txt"))] (with-config {:tasks {:clean [:shell :clean:sum] @@ -60,7 +61,7 @@ (let [res (bb :clean:sum)] (is (= 6 res))) (is (not (fs/exists? temp-file))))))) - (testing ":do always continuing" + #_(testing ":do always continuing" (with-config {:tasks {:sum-1 [:babashka "-e" "(do (+ 4 5 6) nil)"] :sum-2 [:babashka "-e" "(+ 1 2 3)"] :all [:babashka :sum-1:sum2]}} @@ -69,18 +70,18 @@ :sum [:babashka "-e" "(+ 1 2 3)"] :all[:babashka :div-by-zero:sum] }} (is (= 6 (bb :all))))) - (testing ":and-do failing" + #_(testing ":and-do failing" (with-config {:tasks {:div-by-zero [:babashka "-e" "(/ 1 0)"] :sum [:babashka "-e" "(+ 1 2 3)"] :all [:babashka :div-by-zero:sum]}} (is (thrown-with-msg? Exception #"Divide" (bb :all))))) - (testing ":or-do short-cutting" + #_(testing ":or-do short-cutting" (with-config {:tasks {:sum-1 [:babashka "-e" "(+ 1 2 3)"] :sum-2 [:babashka "-e" "(+ 4 5 6)"] :all [:or [:sum1] [:sum2]]}} (is (= 6 (bb :all))))) - (testing ":or-do succeeding after failing" + #_(testing ":or-do succeeding after failing" (with-config {:tasks {:div-by-zero [:babashka "-e" "(/ 1 0)"] :sum [:babashka "-e" "(+ 1 2 3)"] :all [:babashka [:or [:div-by-zero] [:sum]]]}}