From 864c30ef1557a955cb894b823d541b97b52cd17d Mon Sep 17 00:00:00 2001 From: Michiel Borkent Date: Mon, 5 Oct 2020 22:11:21 +0200 Subject: [PATCH] [#606] Fix System/exit in REPL --- src/babashka/main.clj | 5 ----- test/babashka/main_test.clj | 10 +--------- 2 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/babashka/main.clj b/src/babashka/main.clj index 5fd5d319..e6a68e7c 100644 --- a/src/babashka/main.clj +++ b/src/babashka/main.clj @@ -398,10 +398,6 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that 'org.httpkit.sni-client @(resolve 'babashka.impl.httpkit-client/sni-client-namespace)) features/httpkit-server? (assoc 'org.httpkit.server @(resolve 'babashka.impl.httpkit-server/httpkit-server-namespace)))) -(def bindings - {'java.lang.System/exit exit ;; override exit, so we have more control - 'System/exit exit}) - (def imports '{ArithmeticException java.lang.ArithmeticException AssertionError java.lang.AssertionError @@ -540,7 +536,6 @@ If neither -e, -f, or --socket-repl are specified, then the first argument that (fn [ctx & opts] (let [opts (apply hash-map opts)] (repl/start-repl! ctx opts))))) - :bindings bindings :env env :features #{:bb :clj} :classes classes/class-map diff --git a/test/babashka/main_test.clj b/test/babashka/main_test.clj index 5a7f608f..f5f3ffd0 100644 --- a/test/babashka/main_test.clj +++ b/test/babashka/main_test.clj @@ -121,15 +121,7 @@ (let [res (bb nil "-f" "test/babashka/scripts/System.bb")] (is (= "bar" (second res))) (doseq [s res] - (is (not-empty s)))) - (let [out (java.io.StringWriter.) - err (java.io.StringWriter.) - exit-code (sci/with-bindings {sci/out out - sci/err err} - (binding [*out* out *err* err] - (main/main "(println \"Hello world!\") (System/exit 42)")))] - (is (= (str out) "Hello world!\n")) - (is (= 42 exit-code)))) + (is (not-empty s))))) (deftest malformed-command-line-args-test (is (thrown-with-msg? Exception #"File does not exist: non-existing\n"