powderkeg 2017-03-12

didn’t figure out what is different with lein test to saying in a repl (run-tests ‘powderkeg.integration-test)

classloader thing maybe

since: Unable to find class: powderkeg.core$may_unmap_tuple2$fn__3729

Show me the ns form for the test ns

It's most certainly due to a behavior of ouroboros that could be improved: it has to be one of the earliest loaded namespace.

Maybe lein messes with loading order.

Hmm not sure since the missing class is in keg core. And keg core requires ouroboros.

tried this:

0% cat run-integration-test.clj
(require 'clojure.test)
(require 'powderkeg.integration-test)
(clojure.test/run-tests ‘powderkeg.integration-test)

folowed by

java -cp `lein with-profile +test classpath` clojure.main run-integration-test.clj

and get the same error

but if I just do

0% java -cp `lein with-profile +test classpath` clojure.main
Clojure 1.8.0
user=> (load-file “run-integration-test.clj”)

this seems to work

stuff works different in repl 🙂

on my machine, yes

I'll have a look at it tomorrow. No clue at the moment.

yep, might be with the kids now 🙂

interesting:

java -cp `lein with-profile +test classpath` clojure.main -i run-integration-test.clj -r
makes the test work, though one ends up in a repl afterwards

so hacked a bit more, tried this: snipplet

(let [cl (.getContextClassLoader (Thread/currentThread))]
  (.setContextClassLoader (Thread/currentThread) (clojure.lang.DynamicClassLoader. cl)))
from https://github.com/clojure/clojure/blob/master/src/clj/clojure/main.clj#L220-L221

this seems to work:

0% cat run-integration-test.clj
(let [cl (.getContextClassLoader (Thread/currentThread))]
  (.setContextClassLoader (Thread/currentThread) (clojure.lang.DynamicClassLoader. cl)))
(require 'clojure.test)
(require 'powderkeg.integration-test)
(clojure.test/run-tests 'powderkeg.integration-test)
(System/exit 0)
0% java -cp `lein with-profile +test classpath` clojure.main run-integration-test.clj

so didn’t want to stop hacking, but learned that clojure.lang.DynamicClassLoader seems to be needed, simplistic test that runs Spark 2 with docker seems to work now: https://circleci.com/gh/viesti/powderkeg/9