kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
defa 2021-03-08T08:22:12.034Z

Kaocha stopped working for no obvious reason. No error, just stuck:

% ./scripts/kaocha.sh        
[(.)
… and then nothing. Process does not terminate. With no tests, kaocha terminates but with even the most trivial test:
(deftest simple
  (testing "never fails"
    (is true)))
it gets stuck. Same if I let the test fail (is false). Any ideas what is happening here. Did work flawlessly before.

defa 2021-03-08T08:23:49.034100Z

This is my kaocha.sh:

#!/usr/bin/env bash
clojure -A:test "$@"

defa 2021-03-08T08:44:50.034300Z

Typing ctr-c in terminal terminates kaocha and prints the expected result.

defa 2021-03-08T08:45:20.034500Z

Have not found anything that allows verbose output.

defa 2021-03-08T08:46:05.034700Z

My tests.edn is this:

;; tests.edn
#kaocha/v1
    {:tests [{:id                             :unit-cljs
              :type                           :kaocha.type/cljs
              :src-paths                      ["src/main"]
              :test-paths                     ["src/test"]
              :ns-patterns                    ["-test$"]}]}

plexus 2021-03-08T09:28:37.035Z

Could you, once it has gotten stuck - use jcmd to find the process id of the kaocha process - use jstack to get the stack traces of that process - share those (via http://gist.github.com/) ? That way we can see exactly where it's stuck.

plexus 2021-03-08T09:28:51.035200Z

please also share your deps.edn so we get the exact version you're using.

plexus 2021-03-08T09:30:02.035400Z

and if you could then put all of the above into https://github.com/lambdaisland/kaocha/issues that would be 🙏:skin-tone-2: 🙏:skin-tone-2: 🙏:skin-tone-2: :thanks2: 🎉

plexus 2021-03-08T09:31:41.035600Z

it's probably also a good idea to add :capture-output? false to your tests.edn, to make sure there aren't any warnings or other relevant output that's getting hidden.

plexus 2021-03-08T09:33:16.035800Z

You could also use :reporter :kaocha.report/debug to get more verbose output, not sure how much that will tell us but it can't hurt.

defa 2021-03-08T10:00:31.036Z

Thanks @plexus, I will try later and let you know. If it still persists I’ll open an issue. Still have the feeling that it is something stupid on my side that I don’t see yet 😉

defa 2021-03-08T10:44:39.036200Z

Okay, I found the troublemaker… I recently added some code to collect runtime stats in my re-frame based react native app with something like:

(defonce stats (atom {:counter 0}))

(defonce condition-eval-stats-timer
         (js/setInterval (fn []
                           (swap! stats update :counter inc))
                         1000))
When removing the js/setInverval kaocha behaves as expected. When isolating the problem in a minimal project I get this error after a while:
% ./bin/kaocha 
WARNING: When invoking clojure.main, use -M
[(.)E]
Randomized with --seed 1001458186

ERROR in unit-cljs (main.java:40)
Unexpected error executing kaocha-cljs test suite.
Exception: clojure.lang.ExceptionInfo: Failed cleaning up ClojureScript runtime
{:cljs/last-val "nil", :ws/disconnected? true, :ws/connected? false}
 at kaocha.type.cljs$eval6734$fn__6736$fn__6758.invoke (cljs.clj:302)
    kaocha.type.cljs$queue_consumer.invokeStatic (cljs.clj:181)
    kaocha.type.cljs$queue_consumer.invoke (cljs.clj:173)
    kaocha.type.cljs$eval6734$fn__6736.invoke (cljs.clj:298)
    ...
    kaocha.plugin.capture_output$capture_output_wrap_run_hook$fn__2618$fn__2619.invoke (capture_output.clj:83)
    ...
    kaocha.plugin.capture_output$capture_output_wrap_run_hook$fn__2618.doInvoke (capture_output.clj:83)
    ...
    kaocha.testable$run.invokeStatic (testable.clj:128)
    kaocha.testable$run.invoke (testable.clj:119)
    kaocha.testable$run_testable.invokeStatic (testable.clj:212)
    kaocha.testable$run_testable.invoke (testable.clj:157)
    kaocha.testable$run_testables.invokeStatic (testable.clj:225)
    kaocha.testable$run_testables.invoke (testable.clj:215)
    kaocha.api$run$fn__3124$fn__3125$fn__3126.invoke (api.clj:137)
    ...
    kaocha.api$run$fn__3124$fn__3125.invoke (api.clj:111)
    ...
    kaocha.api$run$fn__3124.invoke (api.clj:110)
    ...
    kaocha.api$run.invokeStatic (api.clj:96)
    kaocha.api$run.invoke (api.clj:83)
    kaocha.runner$run.invokeStatic (runner.clj:133)
    kaocha.runner$run.invoke (runner.clj:74)
    kaocha.runner$_main_STAR_.invokeStatic (runner.clj:172)
    kaocha.runner$_main_STAR_.doInvoke (runner.clj:145)
    ...
    kaocha.runner$_main.invokeStatic (runner.clj:183)
    kaocha.runner$_main.doInvoke (runner.clj:181)
    ...
0 tests, 1 assertions, 1 errors, 0 failures.
If opening an issue is still worth doing, please let me know and I will do so.

defa 2021-03-08T10:57:12.036500Z

Gist with stacktrace as requested above: https://gist.github.com/kreutter/e1e445da2ff6d4815d8b7ba4eff77e00

plexus 2021-03-08T14:19:33.036700Z

Ok I missed that this is a kaocha-cljs issue, please mention that LOUD AND CLEAR next time, that's a completely different ball game than just plain kaocha

defa 2021-03-08T15:25:22.036900Z

Okay. I promise. But is that behaviour expected or a bug? Should I raise an issue or not?

plexus 2021-03-08T15:26:47.037100Z

When happens when you eval that code in a vanilla cljs repl?

plexus 2021-03-08T15:27:41.037300Z

hmm seems to work fine, yeah please file an issue. You can find information in the kaocha-cljs repo for getting verbose output from kaocha-cljs

plexus 2021-03-08T15:29:04.037500Z

I'm not sure we'll be able to do much about it, or if we'll even be able to really tell where it's going wrong. Kaocha-cljs is quite hard to troubleshoot. Kaocha-cljs2 is easier to pick apart but it's more work to put set up.

plexus 2021-03-08T15:29:57.037700Z

but I'd still be interested to see your output with kaocha-cljs debugging turned on. Also please read the information in the kaocha-cljs README. kaocha-cljs works with a ClojureScript (p)repl under the hood, which is where most of its limitations stem from.