From 9a8bf7d0c32bad1121278f168fe2a577b4471319 Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Sat, 8 May 2021 11:01:32 +0200 Subject: [PATCH] [#825] Handle uneval-ed expressions in bb tasks --- src/babashka/impl/tasks.clj | 12 ++++++++---- test/babashka/impl/tasks_test.clj | 15 +++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/babashka/impl/tasks.clj b/src/babashka/impl/tasks.clj index 38c72b70..0cd1e7db 100644 --- a/src/babashka/impl/tasks.clj +++ b/src/babashka/impl/tasks.clj @@ -360,10 +360,14 @@ loc (zip/find-value loc :tasks) loc (zip/right loc) loc (zip/down loc)] - (filter symbol? - (map zip/sexpr - (take-while #(not (zip/end? %)) - (take-nth 2 (iterate zip/right loc))))))) + (->> + loc + (iterate zip/right) + (take-nth 2 ) + (take-while #(not (zip/end? %))) + (filter zip/sexpr-able?) + (map zip/sexpr) + (filter symbol?)))) (defn list-tasks [sci-ctx] diff --git a/test/babashka/impl/tasks_test.clj b/test/babashka/impl/tasks_test.clj index a53f25b4..ba17fbce 100644 --- a/test/babashka/impl/tasks_test.clj +++ b/test/babashka/impl/tasks_test.clj @@ -8,3 +8,18 @@ {'foo {:depends ['bar 'quux]} 'bar {:depends ['quux]}} 'foo)))) + +(t/deftest key-order-test + (let [edn "{:tasks + {;; Development tasks + repl {:doc \"Starts an nrepl session with a reveal window\" + :task (clojure \"-M:reveal-nrepl\")} + + ;; Testing + watch-tests {:doc \"Watch tests and run on change\" + :task (clojure \"-M:test -m kaocha.runner --watch\")} + ;test + #_{:doc \"Runs tests\" + :task (clojure \"-M:test -m kaocha.runner\")} + }}"] + (t/is (= '[repl watch-tests] (sut/key-order edn)))))