diff --git a/src/babashka/main.clj b/src/babashka/main.clj index c51806a8..f5307886 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -544,7 +544,7 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that repl [(repl/start-repl! sci-ctx) 0] socket-repl [(start-socket-repl! socket-repl sci-ctx) 0] nrepl [(start-nrepl! nrepl sci-ctx) 0] - (not (str/blank? expression)) + expressions (try (loop [] (let [in (read-next *in*)] diff --git a/test-resources/babashka/empty.clj b/test-resources/babashka/empty.clj new file mode 100644 index 00000000..e69de29b diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 5c42ed78..f708e38a 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -1,4 +1,5 @@ (ns babashka.main-test + {:clj-kondo/config '{:linters {:unresolved-symbol {:exclude [working?]}}}} (:require [babashka.main :as main] [babashka.test-utils :as test-utils] @@ -489,6 +490,19 @@ (is (= "true\ntrue\nfalse\n" (test-utils/bb nil (.getPath (io/file "test-resources" "babashka" "version.clj")))))) + +(defmethod clojure.test/assert-expr 'working? [msg form] + (let [body (next form)] + `(do ~@body + (clojure.test/do-report {:type :pass, :message ~msg, + :expected :success, :actual :success})))) + +(deftest empty-expressions-test + (testing "bb executes the empty file and doesn't start a REPL" + (is (working? (test-utils/bb nil (.getPath (io/file "test-resources" "babashka" "empty.clj")))))) + (testing "bb executes the empty expression and doesn't start a REPL" + (is (working? (test-utils/bb nil "-e" ""))))) + ;;;; Scratch (comment