Skip to content

Duplicated entries in config when using both #kaocha/v1 and #include #297

@NoahTheDuke

Description

@NoahTheDuke

Hey friends!

I was a little confused about how to best write a tests.edn config that uses #include while also relying on the #kaocha/v1 transformer.

Given tests.edn:

#kaocha/v1
 {:capture-output? true
  :color? true
  :plugins [:capture-output :filter :randomize]
  :reporter [kaocha.report/dots]
  :tests [{:id :all
           :ns-patterns ["-test$"]
           :source-paths ["src"]
           :test-paths ["test"]}]}

The docs recommend writing a tests-ci.edn like:

#kaocha/v1
 #meta-merge
  [{:color? false
    :kaocha.plugin.junit-xml/target-file "junit.xml"
    :plugins ^:append [:kaocha.plugin/junit-xml]}
   #include "tests.edn"]

which then prints a config with:

{:kaocha/tests
 [{:kaocha.testable/desc "all (clojure.test)",
   :kaocha.testable/type :kaocha.type/clojure.test,
   :kaocha.testable/id :all,
   :kaocha/ns-patterns ["-test$"],
   :kaocha/source-paths ["src"],
   :kaocha/test-paths ["test"],
   :kaocha.filter/skip-meta [:kaocha/skip]}],
 :kaocha.plugin.junit-xml/target-file "junit.xml",
 :kaocha/fail-fast? false,
 :kaocha/color? true,
 :kaocha/cli-options {:config-file "tests-ci.edn", :print-config true},
 :kaocha.plugin.randomize/seed 997097312,
 :kaocha.plugin.randomize/randomize? true,
 :kaocha/plugins
 [:kaocha.plugin/randomize
  :kaocha.plugin/filter
  :kaocha.plugin/capture-output
  :kaocha.plugin/randomize
  :kaocha.plugin/filter
  :kaocha.plugin/capture-output
  :capture-output
  :filter
  :randomize],
 :kaocha.plugin.capture-output/capture-output? true,
 :kaocha/reporter [kaocha.report/dots],
 :capture-output? true}

Note that the :kaocha/plugins list has duplicates and is missing the junit plugin.

After much trial and error, this tests-ci.edn works (leave off #kaocha/v1 and qualify all of the keywords):

#meta-merge
 [#include "tests.edn"
  {:kaocha/color? false
   :kaocha.plugin.junit-xml/target-file "junit.xml"
   :kaocha/plugins ^:append [:kaocha.plugin/junit-xml]}]

which produces this config:

{:kaocha/tests
 [{:kaocha.testable/desc "all (clojure.test)",
   :kaocha.testable/type :kaocha.type/clojure.test,
   :kaocha.testable/id :all,
   :kaocha/ns-patterns ["-test$"],
   :kaocha/source-paths ["src"],
   :kaocha/test-paths ["test"],
   :kaocha.filter/skip-meta [:kaocha/skip]}],
 :kaocha.plugin.junit-xml/target-file "junit.xml",
 :kaocha/fail-fast? false,
 :kaocha/color? false,
 :kaocha/cli-options {:config-file "tests-ci.edn", :print-config true},
 :kaocha.plugin.randomize/seed 1405326847,
 :kaocha.plugin.randomize/randomize? true,
 :kaocha/plugins
 [:kaocha.plugin/randomize
  :kaocha.plugin/filter
  :kaocha.plugin/capture-output
  :capture-output
  :filter
  :randomize
  :kaocha.plugin/junit-xml],
 :kaocha.plugin.capture-output/capture-output? true,
 :kaocha/reporter [kaocha.report/dots],
 :capture-output? true}

I don't know exactly how exactly the meta-merge works or when/how the conversion of plain keywords to qualified keywords works, but it seems that there's something funky happening and the docs should probably be updated.

Thanks so much!

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationAn issue or improvement related to documentationfirst issue onlyThese tickets are only for first-time contributors.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status
    Candidate

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions