/polylith-external-test-runner

An external (subprocess) test runner for Polylith

Primary LanguageClojureApache License 2.0Apache-2.0

polylith-external-test-runner

An external (subprocess) test runner for Polylith.

Avoids classloader, daemon thread, and memory usage issues by running tests in a subprocess with only Clojure itself as a dependency.

Note: requires Polylith v0.2.17-alpha or later:

io.github.polyfy/polylith
{:git/tag "v0.2.17-alpha" :git/sha "a1581cc"
 :deps/root "projects/poly"}
;; or:
polylith/clj-poly {:mvn/version "0.2.18"}
;; or:
polylith/clj-poly {:mvn/version "0.2.19"}

Usage

Ensure you are using a recent version Polylith that supports external test runners, as shown above.

Add the following dependency to your :poly alias to make this test-runner available:

io.github.seancorfield/polylith-external-test-runner
{:git/tag "v0.4.0" :git/sha "eb954fe"
 :deps/root "projects/runner"}

In your workspace.edn file, either add this global configuration to run all of your projects' tests in subprocesses:

 :test
 {:create-test-runner
  [org.corfield.external-test-runner.interface/create]}

Alternatively, to run just specific projects in subprocesses, add that :create-test-runner entry to those specific projects.

Finding Java

The test runner checks the JAVA_CMD environment variable and will use that value if set, else it checks the JAVA_HOME environment variable and will use the value ${JAVA_HOME}/bin/java is that is set, else it assumes java is on your classpath and can be used as-is.

Passing JVM Options

Since the tests are executed in a java subprocess, you may need to provide JVM options to control how it runs. You can specify the JVM options for the subprocess in two ways:

  • via the POLY_TEST_JVM_OPTS environment variable,
  • via the poly.test.jvm.opts JVM property.

The former can be set in your shell process, for the poly test command. The latter can be set in the :poly alias via:

  :jvm-opts ["-Dpoly.test.jvm.opts=..."]

The value of the environment variables or the JVM property should either be:

  • a space-separated list of all the JVM options you need,
  • a Clojure keyword that will be looked up as an alias in your workspace-level deps.edn file.

The latter allows multiple options to be specified more easily, and also allows for other aliases to be used in those vectors of options, which are looked up recursively (a similar ability has been proposed for tools.deps.alpha). See this project's deps.edn file for an example (which is used in the tests for this project).

License & Copyright

External test runner copyright (c) 2022-2023, Sean Corfield, Apache Source License 2.0.

Colorizer and string util code copyright (c) 2020-2021, Joakim Tengstrand and others, Eclipse Public Licene 1.0.