parent
decf791000
commit
81f8845d72
8 changed files with 74 additions and 42 deletions
|
|
@ -2,6 +2,11 @@
|
||||||
|
|
||||||
## Unreleased
|
## Unreleased
|
||||||
|
|
||||||
|
- #61: add transit as explicit JVM dependency
|
||||||
|
- #60: transform pod reader error into exception of caller
|
||||||
|
- Switch "out" and "err" messages to print and flush instead of `println` (@justone)
|
||||||
|
- Set TCP_NODELAY on transport socket (@retrogradeorbit)
|
||||||
|
- Allow env vars OS_NAME & OS_ARCH to override os props (@cap10morgan)
|
||||||
- #49: don't log socket closed exception
|
- #49: don't log socket closed exception
|
||||||
|
|
||||||
## ...
|
## ...
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,8 @@
|
||||||
:dependencies [[org.clojure/clojure "1.10.3"]
|
:dependencies [[org.clojure/clojure "1.10.3"]
|
||||||
[nrepl/bencode "1.1.0"]
|
[nrepl/bencode "1.1.0"]
|
||||||
[cheshire "5.10.0"]
|
[cheshire "5.10.0"]
|
||||||
[babashka/fs "0.1.6"]]
|
[babashka/fs "0.1.6"]
|
||||||
|
[com.cognitect/transit-clj "1.0.329"]]
|
||||||
:deploy-repositories [["clojars" {:url "https://clojars.org/repo"
|
:deploy-repositories [["clojars" {:url "https://clojars.org/repo"
|
||||||
:username :env/clojars_user
|
:username :env/clojars_user
|
||||||
:password :env/clojars_pass
|
:password :env/clojars_pass
|
||||||
|
|
|
||||||
|
|
@ -177,14 +177,17 @@
|
||||||
(let [id (get reply "id")
|
(let [id (get reply "id")
|
||||||
id (bytes->string id)
|
id (bytes->string id)
|
||||||
value* (find reply "value")
|
value* (find reply "value")
|
||||||
value (some-> value*
|
[exception value] (try (some->> value*
|
||||||
second
|
second
|
||||||
bytes->string
|
bytes->string
|
||||||
read-fn)
|
read-fn
|
||||||
|
(vector nil))
|
||||||
|
(catch Exception e
|
||||||
|
[e nil]))
|
||||||
status (get reply "status")
|
status (get reply "status")
|
||||||
status (set (map (comp keyword bytes->string) status))
|
status (set (map (comp keyword bytes->string) status))
|
||||||
error? (contains? status :error)
|
error? (or exception (contains? status :error))
|
||||||
done? (or error? (contains? status :done))
|
done? (or error? exception (contains? status :done))
|
||||||
[ex-message ex-data]
|
[ex-message ex-data]
|
||||||
(when error?
|
(when error?
|
||||||
[(or (some-> (get reply "ex-message")
|
[(or (some-> (get reply "ex-message")
|
||||||
|
|
@ -202,8 +205,9 @@
|
||||||
:vars (bencode->vars pod name-str v)}))
|
:vars (bencode->vars pod name-str v)}))
|
||||||
chan (get @chans id)
|
chan (get @chans id)
|
||||||
promise? (instance? clojure.lang.IPending chan)
|
promise? (instance? clojure.lang.IPending chan)
|
||||||
exception (when (and promise? error?)
|
exception (or exception
|
||||||
(ex-info ex-message ex-data))
|
(when (and promise? error?)
|
||||||
|
(ex-info ex-message ex-data)))
|
||||||
;; NOTE: if we need more fine-grained handlers, we will add
|
;; NOTE: if we need more fine-grained handlers, we will add
|
||||||
;; a :raw handler that will just get the bencode message's raw
|
;; a :raw handler that will just get the bencode message's raw
|
||||||
;; data
|
;; data
|
||||||
|
|
|
||||||
|
|
@ -151,7 +151,8 @@
|
||||||
(babashka.pods/add-transit-read-handler! \"java.array\"
|
(babashka.pods/add-transit-read-handler! \"java.array\"
|
||||||
into-array)
|
into-array)
|
||||||
|
|
||||||
"}]
|
"}
|
||||||
|
{"name" "incorrect-edn"}]
|
||||||
dependents)}
|
dependents)}
|
||||||
{"name" "pod.test-pod.loaded"
|
{"name" "pod.test-pod.loaded"
|
||||||
"defer" "true"}
|
"defer" "true"}
|
||||||
|
|
@ -238,7 +239,12 @@
|
||||||
(write out
|
(write out
|
||||||
{"status" ["done"]
|
{"status" ["done"]
|
||||||
"id" id
|
"id" id
|
||||||
"value" (write-fn (first args))}))
|
"value" (write-fn (first args))})
|
||||||
|
pod.test-pod/incorrect-edn
|
||||||
|
(write out
|
||||||
|
{"status" ["done"]
|
||||||
|
"id" id
|
||||||
|
"value" (write-fn {(keyword "foo bar") 1})}))
|
||||||
(recur))
|
(recur))
|
||||||
:shutdown (System/exit 0)
|
:shutdown (System/exit 0)
|
||||||
:load-ns (let [ns (-> (get message "ns")
|
:load-ns (let [ns (-> (get message "ns")
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,10 @@
|
||||||
(require '[pod.test-pod.loaded2 :as loaded2])
|
(require '[pod.test-pod.loaded2 :as loaded2])
|
||||||
(def loaded (loaded2/loaded 1))
|
(def loaded (loaded2/loaded 1))
|
||||||
|
|
||||||
|
(def incorrect-edn-response
|
||||||
|
(try (pod.test-pod/incorrect-edn)
|
||||||
|
(catch Exception e (ex-message e))))
|
||||||
|
|
||||||
(pods/unload-pod pod-id)
|
(pods/unload-pod pod-id)
|
||||||
(def successfully-removed (nil? (find-ns 'pod.test-pod)))
|
(def successfully-removed (nil? (find-ns 'pod.test-pod)))
|
||||||
|
|
||||||
|
|
@ -115,4 +119,5 @@
|
||||||
should-be-1
|
should-be-1
|
||||||
add-sync-meta
|
add-sync-meta
|
||||||
error-meta
|
error-meta
|
||||||
read-other-tag-meta]
|
read-other-tag-meta
|
||||||
|
incorrect-edn-response]
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,9 @@
|
||||||
_ (vreset! ctx-ref ctx)
|
_ (vreset! ctx-ref ctx)
|
||||||
ret (sci/binding [sci/out out
|
ret (sci/binding [sci/out out
|
||||||
sci/err err]
|
sci/err err]
|
||||||
(sci/eval-string* ctx test-program))]
|
(binding [*out* out
|
||||||
|
*err* err]
|
||||||
|
(sci/eval-string* ctx test-program)))]
|
||||||
(assertions out err ret)))
|
(assertions out err ret)))
|
||||||
|
|
||||||
(deftest pod-registry-test
|
(deftest pod-registry-test
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
(ns babashka.pods.test-common
|
(ns babashka.pods.test-common
|
||||||
(:require [clojure.java.io :as io]
|
(:require [clojure.java.io :as io]
|
||||||
|
[clojure.string :as str]
|
||||||
[clojure.test :refer [is]]))
|
[clojure.test :refer [is]]))
|
||||||
|
|
||||||
(def test-program (slurp (io/file "test-resources" "test_program.clj")))
|
(def test-program (slurp (io/file "test-resources" "test_program.clj")))
|
||||||
|
|
@ -9,7 +10,12 @@
|
||||||
;; (.println System/err out)
|
;; (.println System/err out)
|
||||||
;; (.println System/err err)
|
;; (.println System/err err)
|
||||||
(doseq [[expected actual]
|
(doseq [[expected actual]
|
||||||
(map vector '["pod.test-pod"
|
(map vector (replace
|
||||||
|
{::edn-error (if (= "edn"
|
||||||
|
(System/getenv "BABASHKA_POD_TEST_FORMAT"))
|
||||||
|
"Map literal must contain an even number of forms"
|
||||||
|
::dont-care)}
|
||||||
|
'["pod.test-pod"
|
||||||
pod.test-pod
|
pod.test-pod
|
||||||
{:a 1, :b 2}
|
{:a 1, :b 2}
|
||||||
6
|
6
|
||||||
|
|
@ -31,12 +37,15 @@
|
||||||
1
|
1
|
||||||
"add the arguments"
|
"add the arguments"
|
||||||
nil
|
nil
|
||||||
nil]
|
nil
|
||||||
|
::edn-error])
|
||||||
(concat ret (repeat ::nil)))]
|
(concat ret (repeat ::nil)))]
|
||||||
(if (instance? java.util.regex.Pattern expected)
|
(cond (instance? java.util.regex.Pattern expected)
|
||||||
(is (re-find expected actual))
|
(is (re-find expected actual))
|
||||||
|
(= ::dont-care expected) nil
|
||||||
|
:else
|
||||||
(is (= expected actual))))
|
(is (= expected actual))))
|
||||||
(is (= "(\"hello\" \"print\" \"this\" \"debugging\" \"message\")\n:foo\n:foo\n" (str out)))
|
(is (= "(\"hello\" \"print\" \"this\" \"debugging\" \"message\")\n:foo\n:foo\n" (str out)))
|
||||||
(is (= "(\"hello\" \"print\" \"this\" \"error\")\n" (str err))))
|
(is (str/starts-with? (str err) "(\"hello\" \"print\" \"this\" \"error\")" )))
|
||||||
|
|
||||||
(def pod-registry (slurp (io/file "test-resources" "pod_registry.clj")))
|
(def pod-registry (slurp (io/file "test-resources" "pod_registry.clj")))
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue