This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-04-10
Channels
- # announcements (4)
- # asami (36)
- # babashka (11)
- # beginners (31)
- # calva (71)
- # clojure (51)
- # clojure-boston (2)
- # clojure-europe (3)
- # clojure-nlp (4)
- # clojuredesign-podcast (1)
- # clojurescript (30)
- # community-development (25)
- # css (1)
- # cursive (10)
- # datomic (1)
- # events (1)
- # figwheel-main (1)
- # girouette (5)
- # graalvm (18)
- # graphql (1)
- # honeysql (37)
- # instaparse (3)
- # jobs (1)
- # malli (6)
- # polylith (2)
- # releases (3)
- # remote-jobs (5)
- # rum (1)
- # shadow-cljs (16)
- # sql (1)
- # tools-deps (37)
- # vscode (11)
Hey all. I’m trying to use test.check/generators in GraalVM and am getting the following error:
Exception in thread "main" java.io.FileNotFoundException: Could not locate clojure/test/check/generators__init.class, clojure/test/check/generators.clj or clojure/test/check/generators.cljc on classpath.
The demo app is very simple:
(ns test-check.main
(:require
[clojure.spec.alpha :as s]
[clojure.spec.gen.alpha :as gen])
(:gen-class))
(defn -main []
(println "Hello test.check")
(println (gen/generate (s/gen int?)))
(println (gen/generate (s/gen nil?)))
(println (gen/sample (s/gen string?)))
(println (gen/sample (s/gen #{:club :diamond :heart :spade})))
(println (gen/sample (s/gen (s/cat :k keyword? :ns (s/+ number?))))))
With the following in the project.clj
(defproject test-check "0.1.0-SNAPSHOT"
:dependencies [[org.clojure/clojure "1.10.3"]
[org.clojure/test.check "1.1.0"]]
:main test-check.main
:profiles {:uberjar {:aot :all}
:dev {:plugins [[lein-shell "0.5.0"]]}}
:aliases
{"native"
["shell"
"native-image"
"--no-fallback"
"--no-server"
"--report-unsupported-elements-at-runtime"
"--initialize-at-build-time"
"-jar" "./target/${:uberjar-name:-${:name}-${:version}-standalone.jar}"
"-H:Name=./target/${:name}"]
"run-native" ["shell" "./target/${:name}"]})
As a sanity check, I do have other successful native-image
builds going, but am getting hung up on this one… Any advice?@campeterson > and am getting the following error when?
@campeterson fwiw, clojure.test.check is also bundled with babashka and compiled with lein so you could look at that project
Sorry, getting that error when run the executable I built w/ native-image
It builds successfully, but when I run the output, that’s where it chokes
@borkdude I’ll take a look at babashka.
there is also a fix for the randomizer which doesn't work out of the box with graalvm native-image. I logged an issue about this in test.check
Yes, I saw your issue. Was double checking I was using the same flags
That did it! source now looks like this:
(ns test-check.main
(:require
[clojure.spec.alpha :as s]
#_[clojure.spec.gen.alpha :as gen]
)
(:gen-class))
(require '[clojure.test.check.generators :as gen])
(defn -main []
(println "Hello test.check")
(println (gen/generate (s/gen int?)))
(println (gen/generate (s/gen nil?)))
(println (gen/sample (s/gen string?)))
(println (gen/sample (s/gen #{:club :diamond :heart :spade})))
(println (gen/sample (s/gen (s/cat :k keyword? :ns (s/+ number?))))))
Compiles fine and now the executable runs
Nope. Same samples each run
Thanks @borkdude this is all great stuff. I appreciate the help
P.S. I added these lines in and it works as you said https://github.com/babashka/babashka/blob/master/feature-test-check/babashka/impl/clojure/test/check.clj#L6-L27