Fix [#babashka.nrepl/66](babashka/babashka.nrepl#66) (#1630)
This commit is contained in:
parent
8788a3c482
commit
d1580f1a72
4 changed files with 28 additions and 6 deletions
|
|
@ -17,6 +17,7 @@ A preview of the next release can be installed from
|
||||||
- [#1624](https://github.com/babashka/babashka/pull/1624): Use Oracle GraalVM 21 ([@lispyclouds](https://github.com/lispyclouds))
|
- [#1624](https://github.com/babashka/babashka/pull/1624): Use Oracle GraalVM 21 ([@lispyclouds](https://github.com/lispyclouds))
|
||||||
- Use PGO to speed up loops (now 2-3x faster for `(time (loop [val 0 cnt 10000000] (if (pos? cnt) (recur (inc val) (dec cnt)) val)))`!)
|
- Use PGO to speed up loops (now 2-3x faster for `(time (loop [val 0 cnt 10000000] (if (pos? cnt) (recur (inc val) (dec cnt)) val)))`!)
|
||||||
- Bump babashka.cli to 0.7.53
|
- Bump babashka.cli to 0.7.53
|
||||||
|
- Fix [#babashka.nrepl/66](https://github.com/babashka/babashka.nrepl/issues/66)
|
||||||
|
|
||||||
## 1.3.184 (2023-08-22)
|
## 1.3.184 (2023-08-22)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
(defn split-classpath
|
(defn split-classpath
|
||||||
"Returns the classpath as a seq of strings, split by the platform
|
"Returns the classpath as a seq of strings, split by the platform
|
||||||
specific path separator."
|
specific path separator."
|
||||||
([^String cp] (vec (.split cp path-sep))))
|
([^String cp] (vec (when cp (.split cp path-sep)))))
|
||||||
|
|
||||||
(defn get-classpath
|
(defn get-classpath
|
||||||
"Returns the current classpath as set by --classpath, BABASHKA_CLASSPATH and add-classpath."
|
"Returns the current classpath as set by --classpath, BABASHKA_CLASSPATH and add-classpath."
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,18 @@
|
||||||
(ns babashka.impl.nrepl-server
|
(ns babashka.impl.nrepl-server
|
||||||
{:no-doc true}
|
{:no-doc true}
|
||||||
(:require
|
(:require
|
||||||
|
[babashka.impl.classpath :as cp]
|
||||||
[babashka.impl.clojure.core :as core-extras]
|
[babashka.impl.clojure.core :as core-extras]
|
||||||
[babashka.impl.common :as common]
|
[babashka.impl.common :as common]
|
||||||
|
[babashka.nrepl.impl.server :refer [process-msg]]
|
||||||
[babashka.nrepl.server :as server]
|
[babashka.nrepl.server :as server]
|
||||||
[sci.core :as sci]))
|
[sci.core :as sci]))
|
||||||
|
|
||||||
|
(defmethod process-msg :classpath [rf result m]
|
||||||
|
(rf result {:response {"status" ["done"]
|
||||||
|
"classpath" (cp/split-classpath (cp/get-classpath))}
|
||||||
|
:response-for (:msg m)}))
|
||||||
|
|
||||||
(defn start-server!
|
(defn start-server!
|
||||||
([]
|
([]
|
||||||
(start-server! nil))
|
(start-server! nil))
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,16 @@
|
||||||
(ns babashka.impl.nrepl-server-test
|
(ns babashka.impl.nrepl-server-test
|
||||||
(:require
|
(:require
|
||||||
|
[babashka.fs :as fs]
|
||||||
[babashka.impl.nrepl-server :refer [start-server!]]
|
[babashka.impl.nrepl-server :refer [start-server!]]
|
||||||
[babashka.nrepl.server :refer [parse-opt stop-server!]]
|
|
||||||
[babashka.main :as main]
|
[babashka.main :as main]
|
||||||
|
[babashka.nrepl.server :refer [parse-opt stop-server!]]
|
||||||
[babashka.test-utils :as tu]
|
[babashka.test-utils :as tu]
|
||||||
[babashka.wait :as wait]
|
[babashka.wait :as wait]
|
||||||
[bencode.core :as bencode]
|
[bencode.core :as bencode]
|
||||||
[clojure.test :as t :refer [deftest is testing]]
|
[clojure.test :as t :refer [deftest is testing]]
|
||||||
[sci.core :as sci]
|
[sci.core :as sci]
|
||||||
[sci.ctx-store :as ctx-store])
|
[sci.ctx-store :as ctx-store]
|
||||||
|
[babashka.impl.classpath :as cp])
|
||||||
(:import
|
(:import
|
||||||
[java.lang ProcessBuilder$Redirect]))
|
[java.lang ProcessBuilder$Redirect]))
|
||||||
|
|
||||||
|
|
@ -31,6 +33,9 @@
|
||||||
res)
|
res)
|
||||||
res (if-let [status (:sessions res)]
|
res (if-let [status (:sessions res)]
|
||||||
(assoc res :sessions (mapv bytes->str status))
|
(assoc res :sessions (mapv bytes->str status))
|
||||||
|
res)
|
||||||
|
res (if-let [cp (:classpath res)]
|
||||||
|
(assoc res :classpath (mapv bytes->str cp))
|
||||||
res)]
|
res)]
|
||||||
res))
|
res))
|
||||||
|
|
||||||
|
|
@ -189,7 +194,17 @@
|
||||||
(bencode/write-bencode os {"op" "eval" "code" "(set! *unchecked-math* true)"
|
(bencode/write-bencode os {"op" "eval" "code" "(set! *unchecked-math* true)"
|
||||||
"session" session "id" (new-id!)})
|
"session" session "id" (new-id!)})
|
||||||
(let [reply (read-reply in session @id)]
|
(let [reply (read-reply in session @id)]
|
||||||
(is (= "true" (:value reply))))))))
|
(is (= "true" (:value reply)))))
|
||||||
|
(testing "classpath op"
|
||||||
|
(cp/add-classpath "src:test")
|
||||||
|
(bencode/write-bencode os {"op" "classpath"
|
||||||
|
"session" session "id" (new-id!)})
|
||||||
|
(let [reply (read-reply in session @id)
|
||||||
|
cp (:classpath reply)]
|
||||||
|
(is (every? string? cp))
|
||||||
|
(is (pos? (count cp)))
|
||||||
|
;; dev-resources doesn't exist
|
||||||
|
(is (pos? (count (filter fs/exists? cp)))))))))
|
||||||
|
|
||||||
(deftest ^:skip-windows nrepl-server-test
|
(deftest ^:skip-windows nrepl-server-test
|
||||||
(let [proc-state (atom nil)
|
(let [proc-state (atom nil)
|
||||||
|
|
@ -221,5 +236,4 @@
|
||||||
|
|
||||||
;;;; Scratch
|
;;;; Scratch
|
||||||
|
|
||||||
(comment
|
(comment)
|
||||||
)
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue