BetterThanTomorrow / joyride

Making VS Code Hackable like Emacs since 2022
https://marketplace.visualstudio.com/items?itemName=betterthantomorrow.joyride
Other
458 stars 17 forks source link

Pez/nrepl server tests #145

Closed PEZ closed 1 year ago

PEZ commented 1 year ago

Added a test for the nrepl server. Testing that it can be started, that we can evaluate with it, and that we can stop it.

Ran into some strange problems when testing the evaluation results:

PEZ commented 1 year ago

I fail to have a test for starting and stopping the server without it interfering with another test where I need a running server. Might be pointing at problem with Joyride's starting and stopping of the server, or my async test fu. Or both.

PEZ commented 1 year ago

Not sure what I did, but now I can have have the start-stop test enabled without getting the error about the nrepl server alrady running.

However, I notice that the test results summary is not printed when I have run the nrepl tests. Not even with the binding. (Though that shouldn't be needed, since the nrepl server should be stopped at this point...)

PEZ commented 1 year ago

This is the test summary I am referring to:

Ran 17 tests containing 24 assertions.
0 failures, 0 errors.
PEZ commented 1 year ago

I added a test confirming that anything we (println ...) in Joyride code is sent out as out messages. Didn't see an obvious way to do it using the nrepl-client so listening on the next data event and matching out the printed value from the Buffer. WDYT?

borkdude commented 1 year ago

That approach sounds good

borkdude commented 1 year ago

LGTM

PEZ commented 1 year ago

Thanks!

Do you have an idea about why we loose the test results summary? Seems it could be indicating a problem that will come back an bite us.

borkdude commented 1 year ago

However, I notice that the test results summary is not printed when I have run the nrepl tests

Perhaps the binding goes out of scope because of laziness or something?

Is it possible to do an alter-var-root on clojure.core/println with js/console.log the moment the nrepl server stops?

PEZ commented 1 year ago

Is it possible to do an alter-var-root on clojure.core/println with js/console.log the moment the nrepl server stops?

You mean in the test runner code or in the nrepl server code?

borkdude commented 1 year ago

we might as well do that in the nrepl server's code

PEZ commented 1 year ago

I'll see what I can figure out. Will let you know if I run into problems. 😄

PEZ commented 1 year ago

It seems to be this that causes the test summary to disappear:

https://github.com/BetterThanTomorrow/joyride/blob/b051d91ea354034baf6bedae576e2552c4451556/src/joyride/nrepl.cljs#L92-L94

If I remove it, the summary comes back (but also, printlns inside evals stops coming via :out messages).

PEZ commented 1 year ago

Let me know if your LGTM still stands. 😄

borkdude commented 1 year ago

LGTM re-instated ;)