Skip to content

Babashka support #440

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Jun 10, 2022
Merged

Babashka support #440

merged 10 commits into from
Jun 10, 2022

Conversation

frenchy64
Copy link
Contributor

@frenchy64 frenchy64 commented May 18, 2022

The next version of babashka will be able to support schema with these changes.

The main thing to note here is that babashka cannot dynamically create classes (since it runs on graalvm), so cc/fn, cc/defrecord, cc/defprotocol have very different implementations than JVM Clojure.

Here, it mostly amounts to broadening class? checks to also account for sci.lang.Type, which is babashka's representation of dynamically generated classes.

We also use fn identity for s/fn-schema since bb keeps a pool of its own fn classes for each arity, and revert to less optimized CLJS approach in some other places.

Note: in bb, both :clj and :bb reader conditionals are active.

Note: in schema.macros, we can't use reader conditionals (.clj) so if-bb uses system props to determine platform.

Note: bb doesn't support extending print-method via a protocol, so macros/defrecord-schema is used to extend it for each schema primitive.

Bonus: adds pretty pr-str printing in CLJS.

The entire test suite remarkably runs in 0.5 seconds:

$ bash <(curl https://raw.githubusercontent.com/babashka/babashka/master/install) --version 0.8.3-SNAPSHOT --dir .
$ time ./bb test

Testing schema.core-test

Testing schema.macros-test

Testing schema.coerce-test

Testing schema.experimental.abstract-map-test

Testing schema.test-test

Testing schema.utils-test

Ran 121 tests containing 660 assertions.
0 failures, 0 errors.
./bb test  0.46s user 0.05s system 98% cpu 0.517 total

@frenchy64 frenchy64 force-pushed the bb-test-suite branch 2 times, most recently from 665faf9 to c97c3ed Compare May 21, 2022 22:58
@frenchy64 frenchy64 changed the title WIP BB test suite Babashka support May 21, 2022
@frenchy64 frenchy64 marked this pull request as ready for review May 21, 2022 23:08
@frenchy64 frenchy64 requested a review from w01fe May 21, 2022 23:08
@frenchy64 frenchy64 self-assigned this May 21, 2022
Copy link
Member

@w01fe w01fe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🆒

@frenchy64 frenchy64 merged commit c6b5f7c into plumatic:master Jun 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants