-
-
Notifications
You must be signed in to change notification settings - Fork 645
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
cider-test-jump
doesn't work properly from test report
#3533
Comments
The error message comes from either of these: (defun cider--find-var-other-window (var &optional line)
"Find the definition of VAR, optionally at a specific LINE.
Display the results in a different window."
(if-let* ((info (cider-var-info var)))
(progn
(if line (setq info (nrepl-dict-put info "line" line)))
(cider--jump-to-loc-from-info info t))
(user-error "Symbol `%s' not resolved" var)))
(defun cider--find-var (var &optional line)
"Find the definition of VAR, optionally at a specific LINE."
(if-let* ((info (cider-var-info var)))
(progn
(if line (setq info (nrepl-dict-put info "line" line)))
(cider--jump-to-loc-from-info info))
(user-error "Symbol `%s' not resolved" var))) Therefore, please enable nrepl message logging and attach the nrepl logs here. Thanks - V |
Thanks for the quick response @vemv. Here's the requested data: Describe char
Nrepl log messagesWhen I hit nrepl-log-messages
Screenshot |
What if you It should result in a successful request being logged. |
nrepl logs
Result of evaluation:
|
Thanks! I'd recommend restarting emacs, enabling nrepl logging in advance, jacking in and retrying. We're hunting for a "info" request which wasn't successful. There's the possibility no request was sent at all, but let's go step by step. |
...Note that (defun cider-var-info (var &optional all)
"Return VAR's info as an alist with list cdrs.
When multiple matching vars are returned you'll be prompted to select one,
unless ALL is truthy."
+ (when (and var (not (string= var ""))) So that's a possible reason for the request not being sent. You can debug with |
Looks like there is a problem when more than 1 REPL is running and buffer |
Thanks! So it all seems to boil down to Sesman session linking. We've fixed a bunch of those this summer, but not this one in particular. I'll see what I can do - should be feasible.
|
Note to self. A possible algo for determining session friendliness is:
Edit: or we could just save the current repl as a buffer-local variable. |
So, I tracked down where it comes from.
(cider-sync-request:info var nil nil (cider-completion-get-context t)) and (when (save-excursion
(condition-case _
(progn
(up-list)
(check-parens)
t)
(scan-error nil)
(user-error nil))) I'm not 100% sure, but it looks like it returns true if point is inside of parenthesis, and because it actually is, we're trying to get context and at some point the following coder from (defun clojure--looking-at-non-logical-sexp ()
"Return non-nil if text after point is \"non-logical\" sexp.
\"Non-logical\" sexp are ^metadata and #reader.macros."
(comment-normalize-vars)
(comment-forward (point-max))
(looking-at-p "\\(?:#?\\^\\)\\|#:?:?[[:alpha:]]")) Maybe we could just check if the major mode is |
I've tried to update (when (and (not (derived-mode-p 'cider-test-report-mode))
(save-excursion
(condition-case _
(progn
(up-list)
(check-parens)
t)
(scan-error nil)
(user-error nil))))
... and it fixed the problem for me, although maybe it would be better to perform this check earlier. |
Thanks for looking into it! I'm not sure how You can We have #3535 btw, if you have it easy, feel free to try it out. |
Here's the part of source of (defun comment-normalize-vars (&optional noerror)
"Check and set up variables needed by other commenting functions.
All the `comment-*' commands call this function to set up various
variables, like `comment-start', to ensure that the commenting
functions work correctly. Lisp callers of any other `comment-*'
function should first call this function explicitly."
(unless (and (not comment-start) noerror)
(unless comment-start
(let ((cs (read-string "No comment syntax is defined. Use: ")))
(if (zerop (length cs))
(error "No comment syntax defined")
(setq-local comment-start cs)
(setq-local comment-start-skip cs))))
;; comment-use-syntax
Yes, I can reproduce it.
Thanks! Will check it out. |
unfortunately this PR doesn't fix the problem with navigation to the failed test from test report if there are 2 projects. I can reproduce it now 100% when I have 2 or more REPLs running. |
Weird, I could repro the problem and verify that the change fixed it. Make sure to re-eval all relevant code / remove Note that the solution partly relies on state - make sure to restart Emacs, just this time. |
What's the value of It should point at the buffer repl representing that of your current project. |
from the name it looks correct, but after debugging |
Thanks. It would not work if you have any custom code around that performs sesman linking (e.g. |
I don't have any custom code.
(_ (cdr (if ensure
(sesman-ensure-session 'CIDER)
(sesman-current-session 'CIDER)))) which return the wrong session. No idea how to debug it further :) |
I'm at a loss. Say that I'm running two repls for two projects: Haystack and Logjam.
Can you verify what If not, you would have to determine why (If I had to guess, I'd say it's because of the I'd totally get if I was asking for too much to debug (although it would be super useful to have a variety of contributors understand these critical bits). OTOH you can rest assured that the PR would at least fix 80% of the cases. |
Are your projects/repls JVM-clojure only? |
That's correct, I'm getting 2 sessions if I do that as well.
That's also correct, I see the correct session if I call this function. The problem is when you execute
No there are no conflicting namespaces.
No problem, I want to help solving this issue :) |
Yes, both projects are JVM-only. |
I would say it is, deeper in the stack. I'll be checking something, will get back at this thread.
Thanks much! 🙌 |
A simpler way to look at it (which also correctly works for me):
i.e., make sure that If it doesn't, it's because Normally I add |
Just in case, please make sure you're actually using my PR. Sometimes CIDER is defined twice in .emacs.d, e.g. Re-eval
i.e. that you're evaling the intended version. |
I doubt it, because I marked it for
|
Is Otherwise, you'll have to debug why Its path to it is
, then ...Note that it's defined like this:
i.e. the |
If you still don't see it reached, note this post #3533 (comment) |
no, I can reproduce it on Hmm. I evaluated |
(defun sesman-current-session (system &optional cxt-types)
"Get the most relevant current session for the SYSTEM.
CXT-TYPES is a list of context types to consider."
(or (car (sesman--linked-sessions system 'sort cxt-types))
(car (sesman--friendly-sessions system 'sort)))) Here |
Yes, I removed |
That would make sense. Does |
Yes, it does. |
Do your two projects share a current directory, something like that? Maybe you're working on a monorepo? |
No, one of them is not even a git repository. |
Mmm. That would be a severe issue. It's not an area we've been touching. At least I can be rest assured that the PR does what it does correctly. My PR will close this issue. You are free to create an issue that demonstrates how to reproduce wrong results for Please do not mention |
But |
Mmm, I see, it's because the buffer's By making it nil, it will work. Thanks much for the perseverance! |
Could you try https://github.com/clojure-emacs/cider/pull/3535/files again? |
Yes, looks like now the issue is fixed! Thank you! |
Thanks to you 🍻! |
It was quite interesting experience :) BTW, any chance that another stable release with this fix will be on nongnu ELPA any time soon? |
MELPA releases (stable / unstable) are automatically available after any given commit (or tags, for Stable) Does that answer the q? |
I usually stick with |
I think these changes break some other things in emacs which rely on Here's the stacktrace:
|
Got it. I guess a git tag is picked up likewise. I'll create it now.
Fixed on master |
Great! Thank you. Will test it a bit later. |
Expected behavior
When I hit
RET
on a failed test in*cider-test-report*
buffer I jump to corresponding failed test source.Actual behavior
There are 2 possible problems. Assuming the following test report:
expected
word, I'm gettingSymbol ‘com.example.app-test/foo-test’ not resolved
error in the minibuffer.No comment syntax is defined. Use:
. After setting;
, I'm gettingSymbol not resolved
error again.Steps to reproduce the problem
Project files:
deps.edn
:src/com/example/app.clj
:test/com/example/app_test.clj
::test
alias additionally)Environment & Version information
CIDER version information
Lein / Clojure CLI version
Clojure CLI 1.11.1
Emacs version
GNU Emacs 29.1.50 (build 1, aarch64-apple-darwin23.0.0, NS appkit-2487.00 Version 14.0 (Build 23A344)) of 2023-10-06
Operating system
MacOS 14 Sonoma
JDK distribution
The text was updated successfully, but these errors were encountered: