-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Ensure pprint is after load-file #432
Conversation
6b356fa
to
9c12799
Compare
I rewrote the implementation because of some strange bug. I've got the test running in almost all platforms, for some reason one in the matrix is failing. I have no idea why. Works fine locally with the same command. Worked fine with a debug commit added. I have no idea. |
What was wrong with the old implementation? |
In particular - why aren't we using the standard dep mechanisms of nREPL? |
@@ -120,7 +120,7 @@ | |||
false, or string representations of the above)." | |||
[handler] | |||
(fn [{:keys [op pprint] :as msg}] | |||
(handler (if (and pprint (= op "eval")) | |||
(handler (if (and pprint (#{"eval" "load-file"} op)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what this is supposed to do. The op is one of the two?
Attempting to use the dependency mechanism triggered this stacktrace which
eluded my best efforts to debug it.
This is probably the better thing to get eyes on:
https://travis-ci.org/clojure-emacs/cider-nrepl/jobs/257670958
Yes, this says if it's eval or load file, it works because of the
delegation. If load file is before pprint, it will create an evaluation and
pprint will be none the wiser. If it is after pprint, we handle it anyway.
This is absolutely a hack and not the preferred solution.
…On 31 Jul 2017 7:41 am, "Bozhidar Batsov" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/cider/nrepl/middleware/pprint.clj
<#432 (comment)>
:
> @@ -120,7 +120,7 @@
false, or string representations of the above)."
[handler]
(fn [{:keys [op pprint] :as msg}]
- (handler (if (and pprint (= op "eval"))
+ (handler (if (and pprint (#{"eval" "load-file"} op))
I'm not sure I understand what this is supposed to do. The op is one of
the two?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#432 (review)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF2h2o0aXfVen--yAyEHiBXm6ozIrBJwks5sTXcygaJpZM4Ojvyt>
.
|
Sorry for the slow turnaround here, but I've been beyond busy at work lately. As I want to cut a new bugfix release soon I see two options.
|
Out of curiosity I have tried locally modified src/cider/nrepl/middleware/pprint.clj
@@ -127,7 +127,7 @@
(set-descriptor!
#'wrap-pprint
(cljs/expects-piggieback
- {:requires #{"clone" #'pr-values #'wrap-pprint-fn}
+ {:requires #{"clone" "load-file" #'pr-values #'wrap-pprint-fn}
:expects #{"eval"}
:handles
{"pprint-middleware" and it does not trigger any eval errors or test errors. But I am missing the motivation for this. How is exactly pprint related to load-file? @SevereOverfl0w, is there a specific use case what you have in mind and haven't described in the OP? As to the "one test failing" is travis choking on cider's env matrix. That happens more often than not recently. |
@vspinu Here is the failure build for using that change: https://travis-ci.org/clojure-emacs/cider-nrepl/builds/257670955 If you think that is okay to pass, I can revert to that. The use-case is that vim-fireplace sends a load-file op for some evaluation contexts. This allows that context to have pprint as a result of that evaluation. Currently it works 50% of the time depending on the random ordering. I have a PR open here to add pprint to vim: tpope/vim-fireplace#301 |
I see, only cljs tests are failing. I missed that part.
But then your current PR is the right thing and the previous version was not that meaningful. If my understanding is correct, you want the If so, then your current PR is the right step, but you then have to add "load-file" to modified src/cider/nrepl/middleware/pprint.clj
@@ -120,7 +120,7 @@
false, or string representations of the above)."
[handler]
(fn [{:keys [op pprint] :as msg}]
- (handler (if (and pprint (= op "eval"))
+ (handler (if (and pprint (#{"eval" "load-file"} op))
(assoc msg :transport (pprint-transport msg))
msg))))
@@ -128,7 +128,7 @@
#'wrap-pprint
(cljs/expects-piggieback
{:requires #{"clone" #'pr-values #'wrap-pprint-fn}
- :expects #{"eval"}
+ :expects #{"eval" "load-file"}
:handles
{"pprint-middleware"
{:doc "Enhances the `eval` op by adding pretty-printing. Not an op in itself." |
I didn't think to try both, after my pain with the former. I took advantage
of the fact that the docstring for load file specifically mentions eval as
part of the api.
I will try both this evening and see if they work together okay, or create
more failures.
…On 10 Aug 2017 17:48, "Vitalie Spinu" ***@***.***> wrote:
Here is the failure build for using that change
I see, only cljs tests are failing. I missed that part.
vim-fireplace sends a load-file op for some evaluation contexts.
But then your current PR is the right thing and the previous version was
not that meaningful.
If my understanding is correct, then you want the pprint to *expect*
load-file down the pipeline just like it *expects* eval op, then check if
either eval or load-file is requited and alter the transport. Right?
If so, then your current PR is the right step, but you then have to add
"load-file" to :expects set. Otherwise it still could happen that
load-file appears earlier in the pipeline, not solving your original
issue.
modified src/cider/nrepl/middleware/pprint.clj@@ -120,7 +120,7 @@
false, or string representations of the above)."
[handler]
(fn [{:keys [op pprint] :as msg}]- (handler (if (and pprint (= op "eval"))+ (handler (if (and pprint (#{"eval" "load-file"} op))
(assoc msg :transport (pprint-transport msg))
msg))))
@@ -128,7 +128,7 @@
#'wrap-pprint
(cljs/expects-piggieback
{:requires #{"clone" #'pr-values #'wrap-pprint-fn}- :expects #{"eval"}+ :expects #{"eval" "load-file"}
:handles
{"pprint-middleware"
{:doc "Enhances the `eval` op by adding pretty-printing. Not an op in itself."
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#432 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AF2h2s8GX1WHFcniUcs5Ltjo_2rUoNcqks5sWzREgaJpZM4Ojvyt>
.
|
Without this, pprint works non-deterministically for load-file, as load-file generates an eval operation.
9c12799
to
3662be7
Compare
Failing test passes locally. Could this be confirmed by another or rerun on
the CI? (I have a history of getting the wrong test results)
…On 10 Aug 2017 5:51 pm, "Dominic Monroe" ***@***.***> wrote:
I didn't think to try both, after my pain with the former. I took
advantage of the fact that the docstring for load file specifically
mentions eval as part of the api.
I will try both this evening and see if they work together okay, or create
more failures.
On 10 Aug 2017 17:48, "Vitalie Spinu" ***@***.***> wrote:
> Here is the failure build for using that change
>
> I see, only cljs tests are failing. I missed that part.
>
> vim-fireplace sends a load-file op for some evaluation contexts.
>
> But then your current PR is the right thing and the previous version was
> not that meaningful.
>
> If my understanding is correct, then you want the pprint to *expect*
> load-file down the pipeline just like it *expects* eval op, then check
> if either eval or load-file is requited and alter the transport. Right?
>
> If so, then your current PR is the right step, but you then have to add
> "load-file" to :expects set. Otherwise it still could happen that
> load-file appears earlier in the pipeline, not solving your original
> issue.
>
> modified src/cider/nrepl/middleware/pprint.clj@@ -120,7 +120,7 @@
> false, or string representations of the above)."
> [handler]
> (fn [{:keys [op pprint] :as msg}]- (handler (if (and pprint (= op "eval"))+ (handler (if (and pprint (#{"eval" "load-file"} op))
> (assoc msg :transport (pprint-transport msg))
> msg))))
> @@ -128,7 +128,7 @@
> #'wrap-pprint
> (cljs/expects-piggieback
> {:requires #{"clone" #'pr-values #'wrap-pprint-fn}- :expects #{"eval"}+ :expects #{"eval" "load-file"}
> :handles
> {"pprint-middleware"
> {:doc "Enhances the `eval` op by adding pretty-printing. Not an op in itself."
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#432 (comment)>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/AF2h2s8GX1WHFcniUcs5Ltjo_2rUoNcqks5sWzREgaJpZM4Ojvyt>
> .
>
|
It's a irrelevant failure. Works locally for me. One of the project members could re-run the job. |
load-file can produce an eval message. Non-deterministically load-file
was before/after pprint middleware. This would mean that pprint would
sometimes work for load-file, and not other times, dependent upon a JVM
restart.
This makes tpope/vim-fireplace#301 work
As an aside: I can't get the tests to pass locally even on master, so I'm depending on the CI