From 39e4ea71e99c70af0e2c182391c4ebbdeda832f2 Mon Sep 17 00:00:00 2001 From: Bob Date: Sat, 22 Apr 2023 17:37:17 -0400 Subject: [PATCH] Fix #1189: add test for error message for clojure {:dir "missing-directory"} (#1543) * add test for error message from running clojure task in non-existent dir * make testing string more accurate --- test/babashka/bb_edn_test.clj | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/babashka/bb_edn_test.clj b/test/babashka/bb_edn_test.clj index 574066b0..045f4359 100644 --- a/test/babashka/bb_edn_test.clj +++ b/test/babashka/bb_edn_test.clj @@ -316,7 +316,13 @@ ;; can't properly test this, but `(clojure)` should work with zero args #_(test-utils/with-config (pr-str '{:tasks {foo (-> (clojure) :out prn)}}) - (is (str/includes? (test-utils/bb "(+ 1 2 3)" "run" "foo") "6"))))) + (is (str/includes? (test-utils/bb "(+ 1 2 3)" "run" "foo") "6")))) + (testing "call to run in missing dir gives 'cannot run program' message" + (test-utils/with-config + (pr-str '{:tasks {foo (clojure {:dir "../missingdir"} "-M" "-r")}}) + ; check rough text of error message, specific message about missing directory is OS-dependent + (is (thrown-with-msg? Exception #"Cannot run program .* \(in directory \"\.\.[/\\]missingdir\"\)" + (bb "run" "foo")))))) (deftest list-tasks-test (test-utils/with-config {}