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

Fixup file name and line numbers when evalulating a form #329

Closed
marcomorain opened this issue Sep 20, 2019 · 8 comments
Closed

Fixup file name and line numbers when evalulating a form #329

marcomorain opened this issue Sep 20, 2019 · 8 comments
Assignees

Comments

@marcomorain
Copy link
Contributor

When I eval a chunk of code using the "Calva: evaluate current top level form..." commands, the file name is auto-generated as form-init2144587467489926643.clj, and the line numbers start from 1 for the chunk that I have evaluated.

This leads to confusing data in a stack trace. Let's say I eval a chunk of code in a file named storage_test.clj, and run a test that fails. The output is as follows:

FAIL in (storage-stores-stuff) (form-init2144587467489926643.clj:12)

If instead, I evaluate the entire file, and then run the test, the output changes to:

FAIL in (storage-stores-stuff) (/Users/foo/bar/baz/storage_test.clj:43)

I can click on the string /Users/foo/bar/baz/storage_test.clj:43 in VS Code and be taken directly to that line of code. I cannot click on form-init2144587467489926643.clj:12, which slows me down, and makes it harder to debug problems.

Suggestion:

When Calva evaluates a form, it should specify the filename, column and initial line number when calling nrepl:

https://github.com/nrepl/nrepl/blob/cdd688f22e65580e9b52d9a8def9ad42a530914a/src/clojure/nrepl/middleware/interruptible_eval.clj#L157-L159

This will make everything line up much better.

PEZ added a commit that referenced this issue Sep 20, 2019
@PEZ
Copy link
Collaborator

PEZ commented Sep 20, 2019

Thanks. Looking at this a bit. I am not sure I can fix the actual case you mention with re-rerunning tests (haven't even looked at that yet, so it could be it is entirely fixable), but for regular evaluations it certainly works providing that info.

Will look at it a bit more and see what I can do.

@PEZ PEZ self-assigned this Sep 20, 2019
@PEZ
Copy link
Collaborator

PEZ commented Sep 21, 2019

How do you run those tests, @marcomorain ? My output does not match what you show there...

@PEZ
Copy link
Collaborator

PEZ commented Sep 21, 2019

Can you test this VSIX package out, @marcomorain ? And let me know if it makes the difference you wanted, or not.

@marcomorain
Copy link
Contributor Author

How do I try the package out @PEZ ? I don't see a file anywhere?

@marcomorain
Copy link
Contributor Author

OK, I found the file in the Releases section of GH. Thanks for working on this.

The line numbers are now fixed, but not the file name.

To run tests, I eval the following in the REPL:

(clojure.test/test-var #'name-of-the-test)

@PEZ
Copy link
Collaborator

PEZ commented Sep 24, 2019

Sorry, missed attaching the vsix. 😄

@PEZ
Copy link
Collaborator

PEZ commented Sep 26, 2019

@marcomorain , if you want to dig in to this some, please do. Or, if not, let me know and I'll have another go at it.

@bpringe
Copy link
Member

bpringe commented Nov 25, 2020

The test runner (at least now, not sure about back when this issue was created) shows the file and line number of the failing test when using the test commands as well as when running the test directly from the repl window using clojure.test/test-var.

We do, however, need to make them clickable (maybe this used to be possible, but with the new output window maybe we lost this). I created an issue for this, #851.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants