[#243] ns form doesn't work with socket repl

This commit is contained in:
Michiel Borkent 2020-01-19 20:01:49 +01:00
parent e2cf871dfa
commit 9269f1087f
2 changed files with 6 additions and 2 deletions

View file

@ -14,7 +14,8 @@
:no-doc true} :no-doc true}
babashka.impl.clojure.core.server babashka.impl.clojure.core.server
(:refer-clojure :exclude [locking]) (:refer-clojure :exclude [locking])
(:require [sci.core :as sci]) (:require [sci.core :as sci]
[sci.impl.vars :as vars])
(:import (:import
[clojure.lang LineNumberingPushbackReader] [clojure.lang LineNumberingPushbackReader]
[java.net InetAddress Socket ServerSocket SocketException] [java.net InetAddress Socket ServerSocket SocketException]
@ -44,7 +45,8 @@
(try (try
(sci/with-bindings {sci/in in (sci/with-bindings {sci/in in
sci/out out sci/out out
sci/err err} sci/err err
vars/current-ns (vars/->SciNamespace 'user)}
(swap! server assoc-in [:sessions client-id] {}) (swap! server assoc-in [:sessions client-id] {})
(apply accept args)) (apply accept args))
(catch SocketException _disconnect) (catch SocketException _disconnect)

View file

@ -55,6 +55,8 @@
(is (socket-command "#?(:bb 1337 :clj 8888)" "1337"))) (is (socket-command "#?(:bb 1337 :clj 8888)" "1337")))
(testing "*1, *2, *3, *e" (testing "*1, *2, *3, *e"
(is (socket-command "1\n*1" "1"))) (is (socket-command "1\n*1" "1")))
(testing "*ns*"
(is (socket-command "(ns foo.bar) (ns-name *ns*)" "foo.bar")))
(finally (finally
(if tu/jvm? (if tu/jvm?
(stop-repl!) (stop-repl!)