Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fully serialize pod return values before pr-str'ing #684

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion boot/pod/src/boot/pod.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
(:require
[clojure.set :as set]
[clojure.string :as string]
[clojure.walk :as walk]
[boot.util :as util]
[boot.file :as file]
[boot.xform :as xf]
Expand Down Expand Up @@ -465,7 +466,9 @@
([expr]
(let [{:keys [meta? expr]} (read-string expr)]
(binding [*print-meta* meta?]
(pr-str (eval expr)))))
(->> (eval expr)
(walk/postwalk identity) ; make sure all lazy seqs are realized #683
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

(pr-str)))))
([pod expr]
(let [arg (pr-str {:meta? *print-meta* :expr expr})
ret (with-invoke-in pod (boot.pod/eval-in* arg))]
Expand Down
8 changes: 8 additions & 0 deletions boot/pod/test/boot/pod_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@

))

(deftest lazy-pod-return-value-test-683
(testing "println inside lazy seqs does not end up in return value"
(let [data (range 400)
expected (map #(do (println %) %) data)
pod-result (boot.pod/with-eval-in (boot.pod/make-pod {})
(map #(do (println %) %) ~data))]
(= data pod-result))))

(deftest canonical
(testing "boot.pod/canonical-id"
(is (= 'foo (pod/canonical-id 'foo)) "In case there is no group, return artifact")
Expand Down