Clojurians
#kaocha
<
2018-11-01
>

This page is not created by, affiliated with, or supported by Slack Technologies, Inc.

timgilbert15:11:21

Hi @plexus, thanks for the junit plugin! I was able to get it to work on the command-line, but when I try to configure it via tests.edn I'm not seeing any output.

timgilbert15:11:00

So this is working: clojure -A:test -m kaocha.runner --plugin kaocha.plugin/junit-xml --junit-xml-file target/junit.xml

timgilbert15:11:12

...but then when I use this as my tests.edn I'm getting no output:

;; koacha test config - see 
#kaocha/v1
    {:tests
     [{:id         :unit
       :test-paths ["src/test/clj"]
       :src-paths  ["src/main/clj"]}]

     :plugins
     [:kaocha.plugin/junit-xml]

     :kaocha.plugin.junit-xml/junit-xml-file
     "target/junit.xml"}

plexus15:11:55

hey, thanks for trying it out, let me try that myself and see what happens

timgilbert15:11:04

Thanks! I wasn't sure whether there was some mapping between the CLI and the config file for these options

timgilbert15:11:57

...er, oh, never mind, I see what it's doing now

plexus15:11:24

yeah the general pattern is that plugins check for CLI arguments, then update the config

plexus15:11:34

--print-config can be helpful to see what's going on

timgilbert15:11:28

Oh, my cinfig up there is wrong, the key should be :kaocha.plugin.junit-xml/target-file

plexus15:11:29

oh I know what's going on, it's overwriting the config option

plexus15:11:12

(config [config]
    (if-let [target (get-in config [:kaocha/cli-options :junit-xml-file])]
      (assoc config ::target-file target)
      config))

timgilbert15:11:14

Oh. I do get the same results with the correct key in there. But yeah, that makes sense that it overwrites with nil from the CLI options

plexus15:11:25

that's what it should look like, let me push a new version

timgilbert15:11:13

Awesome, thanks so much. In the meantime I'll try it out with the CLI options on CircleCI.

plexus15:11:07

0.0-13 is out

plexus15:11:46

I guess it would make more sense to have the CLI switch and config key be the same

timgilbert16:11:41

Sweet, 0.0-13 works. I'll let you know if circleci gives me any static from the results

timgilbert16:11:39

I did notice another potential gotcha with the config, which is that when I had both the config file settings present and I used the command-line arguments, I got an exception out of clojure.tools.cli:

% clojure -A:test -m kaocha.runner --plugin kaocha.plugin/junit-xml  --junit-xml-file target/junit.xml
Exception in thread "main" java.lang.AssertionError: Assert failed: (distinct?* (remove nil? (map :long-opt %)))
        at clojure.tools.cli$compile_option_specs.invokeStatic(cli.cljc:268)
        at clojure.tools.cli$compile_option_specs.invoke(cli.cljc:268)
        at clojure.tools.cli$parse_opts.invokeStatic(cli.cljc:677)
        at clojure.tools.cli$parse_opts.doInvoke(cli.cljc:532)
        at clojure.lang.RestFn.invoke(RestFn.java:425)
        at kaocha.runner$_main_STAR_.invokeStatic(runner.clj:79)
        at kaocha.runner$_main_STAR_.doInvoke(runner.clj:72)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:657)
        at clojure.core$apply.invoke(core.clj:652)
        at kaocha.runner$_main.invokeStatic(runner.clj:139)
        at kaocha.runner$_main.doInvoke(runner.clj:137)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:702)
        at clojure.core$apply.invokeStatic(core.clj:657)
        at clojure.main$main_opt.invokeStatic(main.clj:317)
        at clojure.main$main_opt.invoke(main.clj:313)
        at clojure.main$main.invokeStatic(main.clj:424)
        at clojure.main$main.doInvoke(main.clj:387)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.lang.Var.applyTo(Var.java:702)
        at clojure.main.main(main.java:37)

timgilbert16:11:16

I'm assuming it's because the merged config has essentially --plugin foo --plugin foo in it

plexus16:11:16

oh interesting

timgilbert16:11:41

Anyways, kaocha seems great so far, nice job

plexus16:11:18

thanks! don't hesitate to bring up any snags you run into (or feature requests :wink: )

plexus16:11:27

oh yeah I see what's going, the plugin gets registered twice, so its adds its CLI options twice

plexus16:11:48

fixed in 0.0-248

timgilbert16:11:29

Sweet, that works for me for both the with command-line and no command-line cases