joyride

pez 2023-01-06T11:55:52.444659Z

Apropos Add e2e testing there ^: It is a bit mind-boggling that we are using Joyride to test Joyride. What we do is that we run VS Code and then run this:

vscode.commands.executeCommand("joyride.runCode", "(require '[integration-test.runner :as runner]) (runner/run-all-tests)");
It has the added benefit that a lot of Joyride needs to work in order for it to run the tests. So there's an extra layer of smoke testing there. It would have stopped an incident we had a while ago where we released a non-functioning Joyride version.

borkdude 2023-01-06T12:01:30.396889Z

I think it's a nice approach. One potential issue: how do we know for sure that the SCI cljs.test version works and doesn't accidentally mark everything as succesful or forgets to run certain tests? :) Maybe there should be at least some checks on the outside as well after the tests are run? In babashka I do this as follows: test the bb clojure.test version using the host's clojure test and test evaluation of individual things the same way. Then I run several library tests in babashka like we do above with joyride. But at least I've got a layered approach that ensures every layer works

pez 2023-01-06T12:07:01.566989Z

What would such tests look like? We could maybe wrap some known mix of succeeding/failing tests some way that would fail the tests if the result tally of these is wrong...

borkdude 2023-01-06T12:07:29.140689Z

Just added something to my comment above, how I do this in bb

🙏 1
borkdude 2023-01-06T12:10:54.996969Z

we could maybe also just check the expected stdout, or write to a log file in the tests

borkdude 2023-01-06T12:11:07.663309Z

and then verify the output of the log file

pez 2023-01-06T12:11:09.741109Z

To use the host's cljs.test (shadow) we will need to factor the joyride.sci code such that it does not rely in vscode, I think.

borkdude 2023-01-06T12:11:31.740249Z

we don't need to use cljs.test per se, just some assertions will do

borkdude 2023-01-06T12:11:47.401539Z

using electron/node

pez 2023-01-06T12:12:25.906339Z

> we could maybe also just check the expected stdout, or write to a log file in the tests This is where I was going with my first reply above.

borkdude 2023-01-06T12:12:28.601719Z

I think it would be good to check: • The number of tests that have been run Maybe other stuff?

borkdude 2023-01-06T12:12:38.365249Z

right

pez 2023-01-06T12:13:40.771089Z

But write some special tests for this, maybe as simple as one succeeding and one failing, just to see that we don't ”accidentally mark everything as succesful”.

borkdude 2023-01-06T12:13:50.390329Z

yeah

borkdude 2023-01-06T12:15:09.823709Z

or maybe do this in some tests: add something to a global state and then at the end of the test suite, we verify in the integration test runner that the global state thing is as expected

borkdude 2023-01-06T12:15:22.763309Z

so we know at least the coverage has been as expected

borkdude 2023-01-06T12:15:47.866549Z

I think maybe in the cljs test multimethods this would work

borkdude 2023-01-06T12:16:00.140219Z

so we can confirm the number of assertions made, I think that's sufficient

borkdude 2023-01-06T12:16:36.784779Z

I have trust that assertions work, so if we can just assert that "at least x assertions" have been made, it's good

pez 2023-01-06T12:18:32.558899Z

Cool. I've added an issue about this now: https://github.com/BetterThanTomorrow/joyride/issues/138

👍 1
pez 2023-01-06T12:31:42.984389Z

We already keep a counter of successes and failures in an atom, a slight change to where we report back on the test run success of failure should do it. Like so:

(defmethod cljs.test/report [:cljs.test/default :end-run-tests] [m]
  (old-end-run-tests m)
  (let [{:keys [running pass fail error]} @db/!state
        passed-minimum-threshold 20]
    (println "Runner: tests run, results:" (select-keys  @db/!state [:pass :fail :error]))
    (if (or (> 0 (+ fail error))
            (< pass passed-minimum-threshold))
      (p/reject! running true)
      (p/resolve! running true))))

borkdude 2023-01-06T12:32:45.322469Z

Nice