kaocha

Official support channel: https://clojureverse.org/c/projects/kaocha
defa 2020-11-10T07:19:53.062100Z

It seems that :main-opts in deps.edn overrides -m kaocha.runner "$@" in bin/kaocha :

#!/usr/bin/env bash
clojure -J-Dconfig.file=./conf/server.edn \
        -M:shared:shared_test:server:server_test \
        -m kaocha.runner "$@"
where in deps.edn the I have :main-opts defined in the server alias. Any idea? Can't fine anything useful in docs or maybe it's to early in the morging?

plexus 2020-11-11T15:27:32.067700Z

Apparently using -A to use an alias without its :main-opts is fine, and the warning will go away again in future versions... or so I've been told

practicalli-john 2020-11-12T13:00:48.069100Z

@defa -A still runs main-opts, although that will be removed in later versions. -M is the replacement for -A. -M will run the :main-opts from the last alias in a chain, so for -M:shared:shared_test:server:server_test then only the :main-opts in :server_test should run. However, the command line should over-ride the the aliases. I would try using

clojure -J-Dconfig.file=./conf/server.edn \
        -A:shared:shared_test:server:server_test \
        -M -m kaocha.runner "$@"
Also check you have the latest Clojure CLI version 1.10.1.727 If that doesn't work, probably worth asking in #tools-deps

defa 2020-11-13T06:15:04.076600Z

@jr0cket Thanks for the explanation. As @plexus suggested, I just moved the :main-opts so a separate alias...

:server_main    {:jvm-opts    ["-Dfile.encoding=UTF-8"]
                          :main-opts   ["-m" "acme.server"]}
so I can combine aliases as needed. Currently for kaocha :
clojure -J-Dconfig.file=./conf/server.edn \
        -A:shared:shared_test:server:server_test \
        -m kaocha.runner "$@"

defa 2020-11-10T07:21:51.062300Z

;; tests.edn
#kaocha/v1
    {:tests [{:id                             :unit
              :kaocha/type                    :kaocha.type/clojure.test
              :source-paths                   ["src/shared/clj" "src/server/clj"]
              :test-paths                     ["test/shared/clj" "test/server/clj"]
              :ns-patterns                    ["-test$"]
              :plugins                        [:kaocha.plugin/notifier]
              :kaocha.plugin.notifier/command "terminal-notifier -message %{message} -title %{title} -appIcon %{icon}"
              }]

     }

defa 2020-11-10T07:24:26.062500Z

Instead of running the tests, the server stars up (-> :main-opts ). After removing :main-tops from the server alias in deps.edn will run the tests.

plexus 2020-11-10T07:28:19.062700Z

can you just bind a clojure form to a key?

plexus 2020-11-10T07:29:43.062900Z

Don't use -M:server. Use -A:server or -X:server instead. See clj --help

defa 2020-11-10T07:31:11.063100Z

WARNING: Use of :main-opts with -A is deprecated. Use -M instead.
WARNING: When invoking clojure.main, use -M

plexus 2020-11-10T07:32:47.063300Z

yeah... the core team seems to still be figuring out what they want, but -M will invoke the main-opts you provided for that alias, and you don't want that. So either don't use -M, or split the :main-opts into their own alias

defa 2020-11-10T07:34:22.063500Z

yes, I was thinking about moving :main-opts into a separate alias ...

plexus 2020-11-10T07:35:54.063700Z

-A:aliases     Use aliases to modify classpath
 -X[:aliases]   Use aliases to modify classpath or supply exec fn/args
 -M[:aliases]   Use aliases to modify classpath or supply main opts
I always understood this as allowing you to cherry pick which part of the alias you want to activate, I'm not sure what they're trying to do now, and am not particularly pleased with the breaking changes. Very un-clojure-core-team of them... seems like some of this stuff is still under discussion.

defa 2020-11-10T07:38:16.063900Z

Just checked: clojure -A:a1:a2:a3:a4 -m kaocha.runner "$@" does not run kaocha if there are :main-opts in an alias... so I guess I have no choice but adding an additional alias.

defa 2020-11-10T07:54:01.064100Z

@plexus Thanks for the swift reply. It reassures me that not only I find this confusing 😉