Fork me on GitHub
#kaocha
<
2020-11-10
>
defa07:11:53

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?

defa07:11:51

;; 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}"
              }]

     }

defa07:11:26

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.

plexus07:11:43

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

defa07:11:11

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

plexus07:11:47

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

defa07:11:22

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

plexus07:11:54

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

defa07:11:16

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.

defa07:11:01

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

plexus15:11:32

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-johnny13:11:48

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

defa06:11:04

@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 "$@"