polylith

2024-12-02T12:42:03.191539Z

I think if found out (after a bit of debugging) that Polylith only includes bricks in its classloader based on the namespace declaration in files from normal namespaces and not from test namespaces, am I right? At least that is what I think I am observing

2024-12-11T08:06:00.366059Z

Yeah will do that today!

🎉 1
2024-12-11T11:27:52.322689Z

@tengstrand Hope this explains it well enough https://github.com/polyfy/polylith/issues/523

tengstrand 2024-12-11T11:36:05.888769Z

You have explained the problem really well! It should be possible to report these problems properly, even for the default test runner, so thanks for reporting this!

2024-12-11T11:38:39.097899Z

No problem. Thank you for listening 🙂

2024-12-02T12:45:57.461909Z

I am getting an exotic not very helpful error (below). This is resolved the moment I add a normal namespace to the classpath that (indirectly) requires the necessary bricks for the test namespace

clojure.lang.ExceptionInfo: Error while evaluating form (do (clojure.core/use (quote clojure.test)) (clojure.core/require (quote my-project.example-test)) (clojure.test/run-tests (quote my-project.example-test))) in class-loader. Cause: java.lang.NullPointerException: Cannot invoke "java.lang.ClassLoader.loadClass(String)" because "class_loader" is null {:form (do (clojure.core/use (quote clojure.test)) (clojure.core/require (quote my-project.example-test)) (clojure.test/run-tests (quote my-project.example-test)))}
	at polylith.clj.core.test_runner_orchestrator.core$__GT_eval_in_project$fn__11520.invoke(core.clj:110)
	at polylith.clj.core.clojure_test_test_runner.core$run_test_statements$fn__35648.invoke(core.clj:59)
...
Caused by: java.lang.NullPointerException: Cannot invoke "java.lang.ClassLoader.loadClass(String)" because "class_loader" is null
	at polylith.clj.core.common.class_loader$invoke_in_STAR_.invokeStatic(class_loader.clj:28)
	at polylith.clj.core.common.class_loader$invoke_in_STAR_.doInvoke(class_loader.clj:27)
	at clojure.lang.RestFn.invoke(RestFn.java:494)

2024-12-02T13:32:25.486389Z

Or maybe I had the wrong assumption/mental model that Polylith was figuring out what bricks belongs together 🙈 It always felt like that hehe, but maybe there was no magic after all

2024-12-02T14:50:26.888789Z

Ok didn't find the exact cause yet, but I'm switching to Sean's test runner which gives me much better feedback

tengstrand 2024-12-02T17:59:18.177289Z

You can include :verbose to the test command to see which namespaces that are included.

2024-12-02T21:40:39.258029Z

I did try verbose and it was telling me the namespace was included, but it was still not obvious what the problem was with that namespace. I've seen different scenarios where I was just guessing what was wrong. Sean's test runner points me to the exact line and cause so that is a big difference.

👍 1
tengstrand 2024-12-11T07:29:44.581379Z

Could you summarise this in an issue, and include the improved error message that Sean's test runner gave you? That would help if this is something that can be fixed in the default test runner! @jeroenvandijk

seancorfield 2024-12-02T19:44:12.696869Z

A minor update of my https://github.com/seancorfield/polylith-external-test-runner: • Fix https://github.com/seancorfield/polylith-external-test-runner/issues/11 by supporting :jvm-opts in poly test property handling. • Address https://github.com/seancorfield/polylith-external-test-runner/issues/8 by noting that the standalone poly tool cannot be used with external test runners.

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

❤️ 5
2024-12-02T21:41:25.264309Z

Thank you Sean!