Fork me on GitHub
#polylith
<
2022-08-29
>
Eugen10:08:22

hello, SOLVED how can I pass -Dhyperfiddle.rcf.generate-tests=true to the JVM that runs the tests via poly test? I am trying to get RCF tests in src/ to work . RCF lib converts rcf tests to clojure.test deftests when that option is on. See https://github.com/hyperfiddle/rcf#ci . For some reason, this does not happen when I am running tests in polylith-kaocha. Related comment and PR where I tried https://github.com/imrekoszo/polylith-kaocha/pull/7#issuecomment-1230076907 I did find some information about this in the docs that suggest JVM is reused during tests and only classloader is switched. > This set of tests will be executed in isolation from its own classloader which will speed up the test execution and make it more reliable. I know some setups require JVM forking to ensure a clean classloader. Not sure if this is required at the moment (though I did find strange some class loading issues - but perhaps they are my fault).

Eugen10:08:57

it seems I needed to pass the jvm options to :poly alias

:jvm-opts ["-XX:-OmitStackTraceInFastThrow"
                             ;; Run RCF tests when loading files in REPL
                             ;; 
                    "-Dhyperfiddle.rcf.generate-tests=true"]

Eugen10:08:04

with this solution, a single pair of jvm options will be used for all tests. This might have some implications / require customizations in some cases

Eugen13:08:45

I created a repo to reproduce / document polylith + rcf with default test runner https://github.com/ieugen/poly-rcf . In order for src/ tests to be "discovered" and run, I needed to add "src" to :test :extra-paths in bases/rcf . do you think this is an issue with Poly tool and how it works with tests? In a normal project, this is not needed. Just adding the rcf jvm-option is enough. cc @tengstrand

tengstrand13:08:05

Hi @U011NGC5FFY! I'm busy the whole day, but will try to have a look at this tomorrow.

👍 2
seancorfield19:08:34

This is not Polylith-specific -- test runners, in general, do not look at src to discover tests so the issue you're seeing with RCF is also something you'd see with adding tests via metadata to functions in src namespaces. I talk a bit about this in the documentation for Expectations (a clojure.test-compatible library that provides a more expressive syntax for writing tests): https://cljdoc.org/d/com.github.seancorfield/expectations/2.0.160/doc/getting-started#test-placement

👍 1
Eugen11:08:15

so the solution is to add src paths to test as well? in one PR I did use a polylith-kaocha feature to add src paths to test paths via tooling The simpler way sould be to just add src to test paths as well.

tengstrand12:08:59

Yes @U011NGC5FFY, you need to specify the src directory under the :test alias, the same way you did https://github.com/ieugen/poly-rcf/blob/main/bases/rcf/deps.edn.

Eugen12:08:28

ok, thanks. Do you htink this should be added to the testing docs ?

Eugen13:08:08

I can probably add a PR

seancorfield15:08:29

It's a very unusual approach to have tests in src code -- that's why it does not work by default with any testing tools. I don't think Polylith should encourage it in its documentation. If you want to persuade the RCF team to document that sort of stuff, that's where I think you should focus your energy. RCF is very niche (it's clever stuff -- I used it for a while and you'll see discussions I'm involved with on the RCF repo, trying to reconcile how it works with a REPL-based workflow, since the tests it generates do not have predictable names).

👍 1