Anyone done testing for native executables? Unit tests pass in clojure, jar builds and run fine, native image builds.. then I get an error when I run it.
There are quite a few quirks that you have to be aware of. What is the exact error that you get?
I usually test my native-images with bats.
Exception in thread "main" clojure.lang.ExceptionInfo: capacity < 0: (-8 < 0) {}
at superv.async$throw_if_exception.invokeStatic(async.cljc:128)
at superv.async$throw_if_exception.invoke(async.cljc:121)
at superv.async$_LT__QMARK__QMARK_.invokeStatic(async.cljc:289)
at superv.async$_LT__QMARK__QMARK_.invoke(async.cljc:285)
at datahike.connector$fn__28179.invokeStatic(connector.cljc:154)
at datahike.connector$fn__28179.invoke(connector.cljc:107)
at datahike.connector$fn__28123$G__28112__28128.invoke(connector.cljc:101)
at datahike.connector$connect.invokeStatic(connector.cljc:229)
at datahike.connector$connect.invoke(connector.cljc:225)
at server.core$_main.invokeStatic(core.clj:31)
at server.core$_main.invoke(core.clj:27)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at server.core.main(Unknown Source)
Caused by: java.lang.IllegalArgumentException: capacity < 0: (-8 < 0)
at java.nio.Buffer.createCapacityException(Buffer.java:279)
at java.nio.ByteBuffer.allocate(ByteBuffer.java:362)
at konserve.filestore$read_file.invokeStatic(filestore.clj:303)
at konserve.filestore$read_file.invoke(filestore.clj:281)
at konserve.filestore$io_operation$fn__21896$state_machine__5020__auto____21947$fn__21949.invoke(filestore.clj:562)
at konserve.filestore$io_operation$fn__21896$state_machine__5020__auto____21947.invoke(filestore.clj:553)
at clojure.core.async.impl.ioc_macros$run_state_machine.invokeStatic(ioc_macros.clj:978)
at clojure.core.async.impl.ioc_macros$run_state_machine.invoke(ioc_macros.clj:977)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invokeStatic(ioc_macros.clj:982)
at clojure.core.async.impl.ioc_macros$run_state_machine_wrapped.invoke(ioc_macros.clj:980)
at clojure.core.async.impl.ioc_macros$take_BANG_$fn__5038.invoke(ioc_macros.clj:991)
at clojure.core.async.impl.channels.ManyToManyChannel$fn__1075.invoke(channels.clj:139)
at clojure.lang.AFn.run(AFn.java:22)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at clojure.core.async.impl.concurrent$counted_thread_factory$reify__962$fn__963.invoke(concurrent.clj:29)
at clojure.lang.AFn.run(AFn.java:22)
at java.lang.Thread.run(Thread.java:833)
at com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine(PlatformThreads.java:704)
at com.oracle.svm.core.posix.thread.PosixPlatformThreads.pthreadStartRoutine(PosixPlatformThreads.java:202)There is a few places I can look at in the code from my end. But manually running the executable to find this error is less than ideal.
https://clojurians.slack.com/archives/CAJN79WNT/p1653307678278149
@grounded_sage All my native projects are tested with Clojure, but I usually do that by shelling out to the command line application and then run the regular tests in the JVM
Including clojure.test inside a native image might not be optimal for binary size, so you'd have to compile it at least twice.
hmm maybe bundling in clojure.test isn't a bad idea for testing purposes. I have a minimal repo so it blows up as soon as I run it. But I have concerns that it may not be like this for larger applications.
@grounded_sage see also https://github.com/clj-easy/graal-docs/blob/master/doc/testing-strategies.md