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

Unwanted newlines are added to REPL output of Kaocha test run #1826

Closed
bartkl opened this issue Aug 10, 2022 · 10 comments
Closed

Unwanted newlines are added to REPL output of Kaocha test run #1826

bartkl opened this issue Aug 10, 2022 · 10 comments

Comments

@bartkl
Copy link

bartkl commented Aug 10, 2022

Hi,

As discussed on Slack, when running tests in the REPL with Kaocha with the standard reporter, the dots summary is broken up on newlines, hurting readability.

The correct output looks like:

[(.)(FFF)] (run in command-line REPL through Leiningen)

However, when I run these tests the same way in Calva's REPL, these characters get broken up:

[
(
.
)
(
F
F
F
)
]

(run in Calva REPL)

As I understand the brilliant debugging done by some Clojurians on Slack, the issue arises because Kaocha sends these characters one by one, and Calva adds newline characters each time nREPL receives a character.

Anyways, @PEZ asked me to submit this issue, so here we are. As requested, here's the nREPL log from Calva (truncated for relevance):

REPL output (Calva)
-> sent
{
  id: '765',
  op: 'eval',
  session: 'abc677b9-dbad-4955-b137-7e4c12c174a7',
  code: '(k/run :unit)',
  file: '/home/bartkl/Programming/alliander-opensource/metamorph/.calva/output-window/output.calva-repl',
  line: 435,
  column: 1,
  stdout: [Function: stdout],
  stderr: [Function: stderr],
  pprint: false
}

<- received
{
id: '765',
out: '[',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: '(',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: '.',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: ')',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: '(',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: '\x1B[31mF\x1B[m',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: '\x1B[31mF\x1B[m',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: '\x1B[31mF\x1B[m',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: ')',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: ']',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}

<- received
{
id: '765',
out: '\nRandomized with --seed 485325480\n',
session: 'abc677b9-dbad-4955-b137-7e4c12c174a7'
}
... truncated for relevance

Thanks!

@PEZ
Copy link
Collaborator

PEZ commented Aug 10, 2022

Thanks! As discussed on Slack this probably has a solution where Calva does not add newlines when receiving data for stdout. It might not be super easy, though, because I can imagine it getting tricky to determine when a newline should be added and when it shouldn't. Then again, maybe we have made this more complicated than it needs be, in Calva. It does seem like never adding newlines not received should be correct. We'll see when we attempt to fix this issue, I guess.

@bartkl
Copy link
Author

bartkl commented Aug 10, 2022

It does seem like never adding newlines not received should be correct. We'll see when we attempt to fix this issue, I guess.

This was an immediate question I had. So that's the first attempt? To simply never add newlines and see how that looks? And does testing that involve passing unit tests or are we talking about human verification by using the REPL?

@PEZ
Copy link
Collaborator

PEZ commented Oct 29, 2022

Sorry for dropping this ball, @bartkl! @Gnurdle reminded me about it. And from what I can see our idea of just never adding newlines works. It was a bit more involved than that to actually make it so, because I had made quite a mess of the printing way back. Can't even figure out why I did all that funny stuff. 😄

Anyway, here's a VSIX that I'd like help to test. It fixes the Kaocha printouts, but I might also have introduced some regression elsewhere...

https://output.circle-artifacts.com/output/job/f06787fa-e471-4108-a24f-14dbd1487ba9/artifacts/0/tmp/artifacts/calva-2.0.312-1826-eval-print-wo-newlines-eb4664d4.vsix

The PR:

@bartkl
Copy link
Author

bartkl commented Oct 30, 2022

No problem!

And I'm happy to help. I just installed the VSIX and tried it out, but to no avail. The kaocha output is still like before:

(k/run 'metamorph.core-test)
[
(
.F)]
Randomized awith --seed 235856045

Even after first uninstalling Calva and then reinstalling the VSIX (using code --install-extension) it still displays that output :(.

If I can do more to help, let me know. Thanks!

@PEZ
Copy link
Collaborator

PEZ commented Oct 30, 2022

Thanks for being so quick on testing! I'll try to figure out what's going on.

@PEZ
Copy link
Collaborator

PEZ commented Oct 30, 2022

Hmmm, I was thinking maybe something was funny with the VSIX, but it behaves as intended... How do you install the VSIX? Maybe code --install-extension installs the marketplace version. You can also check which version you actually are using by hovering the Calva entry in the Extensions pane.

image

The way I install VSIXs is from that pane's top meatballs menu: Install from VSIX...

@bartkl
Copy link
Author

bartkl commented Oct 30, 2022

I tried your way of installing too, and hovering over the Calva extension tells me:

v2.0.312-1826-eval-print-wo-newlines-eb4664d4

Which seems good. The Last updated timestamp also makes sense. I reloaded everything, and it still doesn't work :(.

Could this have something to do with me being on Linux? With regards to the line endings?

@Gnurdle
Copy link
Contributor

Gnurdle commented Oct 30, 2022

Also on linux. Clojurescript/Node.

The update seems to fix the issue I was talking about:
for example, eval-ing this in a buffer:

(doseq [i (range 10)] (println "gotta " i))

now in (.312) produces repl output w/o extra newlines whereas 311 has them

@PEZ
Copy link
Collaborator

PEZ commented Oct 30, 2022

@bartkl, it's baffling. Your Calva behaves just like if it hasn't been updated. I'm on Mac so we should have the same line ending scheme. Also, what the change should do is to just not add newlines, so whatever scheme shouldn't matter. Can you try with VS Code Insiders? https://code.visualstudio.com/insiders/

@bartkl
Copy link
Author

bartkl commented Oct 30, 2022

Clever, @PEZ. And I can confirm it works in that isolated VS Code Insiders. So something's wrong with my current installation. I might simply reinstall everything and see what happens ;).

The fix seems fine, that's for sure.

Edit: I just accidently deleted my entire VS Code config. What better timing! ;)

Thanks!

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

No branches or pull requests

3 participants