polyfy / polylith

A tool used to develop Polylith based architectures in Clojure.
Eclipse Public License 1.0
499 stars 47 forks source link

Support snippets of test configuration to be merged into settings #457

Closed tengstrand closed 2 weeks ago

tengstrand commented 3 months ago

There is a need for test configuration to be merged into the settings, e.g. when running the external test runner, see this comment.

We could solve this by adding a :test-configs key to workspace.edn, e.g.

{
 ...
 :test-configs {:external-test-runner {:create-test-runner [org.corfield.external-test-runner.interface/create]}
                :kaocha-test-runner   {:create-test-runner polylith-kaocha.test-runner/create}
                :exclude-stuff        {:org.corfield/external-test-runner {:focus {:exclude [:stuff]}}}}}
                :exclude-integration  {:org.corfield/external-test-runner {:focus {:exclude [:integration]}}}
}

The Kaocha test runner can now be selected with:

poly test with:kaocha-test-runner

Or the External test runner, without the integration tests:

poly test with:external-test-runner:exclude-integration

The idea is that the selected configuration snippets will be merged to the :test key in the workspace configuration, and if the value lives in a collection (e.g. vector or hash map) it will be added to existing values, e.g.:

poly test with:external-test-runner:exclude-integration:exclude-stuff

Will end up as:

:test {:create-test-runner [org.corfield.external-test-runner.interface/create]
       :org.corfield/external-test-runner {:focus {:exclude [:integration :stuff]}}}

If we run commands from a shell, we will also get autocomplete for the with option.

seancorfield commented 3 months ago

That's nice -- it wouldn't support complete ad hoc test settings (per my original discussion on Slack) but it would make it much less verbose to support a specific set of test settings which should be sufficient, and it would be no big deal to add more :test-configs as needed for a given project for any combination of additional settings. A good compromise, esp. with the auto-complete support this would bring.

seancorfield commented 2 weeks ago

Nice! I'll finish up my work on https://github.com/seancorfield/polylith-external-test-runner/issues/5 and https://github.com/seancorfield/polylith-external-test-runner/issues/6 and document usage per this new machinery in Polylith.