Fork me on GitHub

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?


;; tests.edn
    {: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}"



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.


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


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


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


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


-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.


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.


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


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


@U5FKQSSS1 -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 If that doesn't work, probably worth asking in #tools-deps


@U05254DQM Thanks for the explanation. As @U07FP7QJ0 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 "$@"