From 338304cd5c16c41a31f0ff001f78d0aae4f9c5ec Mon Sep 17 00:00:00 2001 From: Jude Payne Date: Wed, 10 May 2023 22:13:00 +0100 Subject: [PATCH] change to arg-meta, fix byte->boolean + added test --- src/babashka/pods/impl.clj | 4 ++-- test-pod/pod/test_pod.clj | 12 +++++++++++- test-resources/test_program.clj | 6 ++++++ test/.DS_Store | Bin 0 -> 6148 bytes test/babashka/.DS_Store | Bin 0 -> 6148 bytes test/babashka/pods/test_common.clj | 1 + 6 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 test/.DS_Store create mode 100644 test/babashka/.DS_Store diff --git a/src/babashka/pods/impl.clj b/src/babashka/pods/impl.clj index 0addfb3..d0beebf 100644 --- a/src/babashka/pods/impl.clj +++ b/src/babashka/pods/impl.clj @@ -29,7 +29,7 @@ (String. bytes)) (defn bytes->boolean [^"[B" bytes] - (boolean bytes)) + (= "true" (String. bytes))) (defn get-string [m k] (-> (get m k) @@ -142,7 +142,7 @@ name-sym (if vmeta (with-meta name-sym vmeta) name-sym) - metadata? (get-maybe-boolean var "read-meta?")] + metadata? (get-maybe-boolean var "arg-meta")] (when metadata? (swap! vars-with-metadata update (:pod-id pod) #(conj (set %) sym))) [name-sym diff --git a/test-pod/pod/test_pod.clj b/test-pod/pod/test_pod.clj index 7241018..9f98c90 100644 --- a/test-pod/pod/test_pod.clj +++ b/test-pod/pod/test_pod.clj @@ -137,7 +137,9 @@ "code" "(defn read-other-tag [x] [x x])" "meta" "{:doc \"unread\"}"} {"name" "round-trip-meta" - "read-meta?" "true"} + "arg-meta" "true"} + {"name" "dont-round-trip-meta" + "arg-meta" "false"} {"name" "-local-date-time"} {"name" "transit-stuff" "code" " @@ -244,6 +246,14 @@ "id" id "value" "#my/other-tag[1]"}) pod.test-pod/round-trip-meta + (write out + {"status" ["done"] + "id" id + "value" + (case format + :transit+json (transit-json-write-meta (first args)) + (write-fn (first args)))}) + pod.test-pod/dont-round-trip-meta (write out {"status" ["done"] "id" id diff --git a/test-resources/test_program.clj b/test-resources/test_program.clj index 245ac98..6bef8d1 100644 --- a/test-resources/test_program.clj +++ b/test-resources/test_program.clj @@ -94,6 +94,11 @@ (= {:my-meta 3} (meta (first (pod.test-pod/round-trip-meta [(with-meta [3] {:my-meta 3})])))) true)) +(def dont-round-trip-meta + (if (= "transit+json" fmt) + (= nil (meta (pod.test-pod/dont-round-trip-meta (with-meta [2] {:my-meta 2})))) + true)) + (require '[pod.test-pod.only-code :as only-code]) (def should-be-1 (only-code/foo)) @@ -128,6 +133,7 @@ assoc-string-array round-trip-meta round-trip-meta-nested + dont-round-trip-meta should-be-1 add-sync-meta error-meta diff --git a/test/.DS_Store b/test/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..4e1b901521fbb96a1ea83582202e851dcd9686cd GIT binary patch literal 6148 zcmeHK%}T>S5Z-O8-B5%c6vR`&YtcrnC|+W%2d_r-pi&cCY-r4urZtCB$OGsL`5?ZI z&g^bPX+0_`Gcfy2<|oO18+J2{G2R?^9LB1QF#(ELuwa-Y7)PCvg7Fjqxw=QfdaTd< zlStmqWRv4JGJtC*SipRxAJ#93WB@VzFb+XCUX_3~CqGD&fysXk22q%d>h%|1D3%r$ z%c3kQ;@a!U)EoJuankgMmw0t1WfbJLADoBXv|U|3lJUq7jd3!fIF7CKG3ScduqU&a`GvoSpp!*jtVIbZUu}_05CRc0an0<)eCc#^Fm< zvScuaCopE1c<_dCB;z}X<#l;JAu&J<5Ceag0kflt%HN#=y*V*J415yS5ZYx#B26mLq)OXjNZUC`la6`c#^(l2x{&(KSjWCu+73n9 z#zVR~Tu9#_kIVow@R0%P{UBAk|Brs||8)=#%m6bmoeaq0VQ|<$ZT4>cQYGEBF7z5o oLUFmlNeT>o6(g3e;w7jS_+2u9zQx=iJP`g7&@}MC4E!kr?<%!bQUCw| literal 0 HcmV?d00001 diff --git a/test/babashka/pods/test_common.clj b/test/babashka/pods/test_common.clj index a71da9f..e0b7d59 100644 --- a/test/babashka/pods/test_common.clj +++ b/test/babashka/pods/test_common.clj @@ -36,6 +36,7 @@ true ;; roundtrip string array true ;; roundtrip metadata true ;; roundtrip metadata nested + true ;; dont roundtrip metadata (when arg-meta "false"/ absent) 1 "add the arguments" nil