exoscale / coax

Clojure.spec coercion library for clj(s)
Other
118 stars 4 forks source link

babashka compat + test runner #25

Closed mathesz closed 2 years ago

mathesz commented 2 years ago

Add compatibility requirements of babashka.

Example usage:

1, Create a clj file, ie: bb-coerce.clj with content

(deps/add-deps {:deps '{org.babashka/spec.alpha {:git/url "https://github.com/babashka/spec.alpha"
                                                      :git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}}})

(deps/add-deps {:deps '{exoscale.coax {:git/url "https://github.com/mathesz/coax"
                                                      :git/sha "3aeec6fd42448befdab8bbe3f598dcc3133cb15d"}}})

(require '[exoscale.coax :as c])
(require '[clojure.spec.alpha :as s])

(s/def ::inst inst?)
(c/coerce! ::inst "2022-02-02")

2, Run the file with babashka

$ bb -f bb-coerce.clj

#inst "2022-02-02T00:00:00.000-00:00"

Test runner

$ bb -f test/exoscale/coax/bb_test_runner.clj

Testing exoscale.coax-test

Ran 19 tests containing 150 assertions.
0 failures, 0 errors.
{:test 19, :pass 150, :fail 0, :error 0, :type :summary}

CLJS tests

$ lein test exoscale.coax-test
OpenJDK 64-Bit Server VM warning: Options -Xverify:none and -noverify were deprecated in JDK 13 and will likely be removed in a future release.
WARNING: abs already refers to: #'clojure.core/abs in namespace: clojure.test.check.generators, being replaced by: #'clojure.test.check.generators/abs

lein test exoscale.coax-test

Ran 19 tests containing 150 assertions.
0 failures, 0 errors.

However $ lein test fails due to babashka dependencies from jvm clojure. I'm not exactly sure how leiningen is being used to run the cljs test runner.

mathesz commented 2 years ago

Just realized that it's already compatible with bb, unless it's pulled from the git source. Since you have already published a clojar version this change has minor benefits.