[#606] Fix System/exit in REPL
This commit is contained in:
parent
5c7f8dedff
commit
864c30ef15
2 changed files with 1 additions and 14 deletions
|
|
@ -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))
|
'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))))
|
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
|
(def imports
|
||||||
'{ArithmeticException java.lang.ArithmeticException
|
'{ArithmeticException java.lang.ArithmeticException
|
||||||
AssertionError java.lang.AssertionError
|
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]
|
(fn [ctx & opts]
|
||||||
(let [opts (apply hash-map opts)]
|
(let [opts (apply hash-map opts)]
|
||||||
(repl/start-repl! ctx opts)))))
|
(repl/start-repl! ctx opts)))))
|
||||||
:bindings bindings
|
|
||||||
:env env
|
:env env
|
||||||
:features #{:bb :clj}
|
:features #{:bb :clj}
|
||||||
:classes classes/class-map
|
:classes classes/class-map
|
||||||
|
|
|
||||||
|
|
@ -121,15 +121,7 @@
|
||||||
(let [res (bb nil "-f" "test/babashka/scripts/System.bb")]
|
(let [res (bb nil "-f" "test/babashka/scripts/System.bb")]
|
||||||
(is (= "bar" (second res)))
|
(is (= "bar" (second res)))
|
||||||
(doseq [s res]
|
(doseq [s res]
|
||||||
(is (not-empty s))))
|
(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))))
|
|
||||||
|
|
||||||
(deftest malformed-command-line-args-test
|
(deftest malformed-command-line-args-test
|
||||||
(is (thrown-with-msg? Exception #"File does not exist: non-existing\n"
|
(is (thrown-with-msg? Exception #"File does not exist: non-existing\n"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue