563f1c588d
Problem: failed equality checks as in "(is (= expected actual))" will give a single, long line of output that for anything but the simplest data structures is unreadable by humans, and the output doesn't give a useful diff. Solution: use library https://github.com/nubank/matcher-combinators and its test directive "match?" which will pinpoint where two data structures differ. Then, instead of "(is (= ...", use "(is (match? expected actual)". It works beautifully. The library offers other nice matchers, but the majority of the time match? is sufficient. Can we use another test runner like Kaocha? kaocha-cljs2 (https://github.com/lambdaisland/kaocha-cljs2) would be able to print better test errors out of the box, among other features, but I have no clue if it would work well or at all in our stack (in theory yes, but it's a larger piece of work). |
||
---|---|---|
.. | ||
README.md | ||
default.nix | ||
deps.json | ||
deps.list | ||
generate.sh |
README.md
Description
This folder contains the scripts and Nix derivations necessary to generate Clojure dependencies for this project.
Usage
Running generate.sh
in a shell that has available shadow-cljs
and clojure
should update the deps.list
and deps.json
files.
Details
By using the following command:
shadow-cljs classpath --force-spawn
We download the necessary JARs into ~/.m2
folder, but also get the classpath printed into standard output.
We skip POM files since they are not necessary, and add edge cases we don't want to handle.
We then use the classpath in combination with contents of ~/.m2
folder to generate the following files:
deps.list
- List of JARs relative to the~/.m2
cache folder.deps.json
- Full list of JARs including their SHAs.
The deps.list
file is just intermediate and for debugging purposes.
The deps.json
is loaded by the derivation in default.nix
and used to produce a derivation that contains all the necessary dependencies:
> grep cljfmt nix/deps/clojure/deps.list
cljfmt/cljfmt/0.6.7/cljfmt-0.6.7.jar
> nix-build --no-out-link -A pkgs.deps.clojure
/nix/store/d7p8r9vhq6z2jmxwakxpcb262wgkc86s-status-mobile-clojure-deps
> DEPS=$(nix-build --no-out-link -A pkgs.deps.clojure)
> find $DEPS -iname 'cljfmt-0.6.7.*'
/nix/store/d7p...86s-status-mobile-clojure-deps/cljfmt/cljfmt/0.6.7/cljfmt-0.6.7.pom.sha1
/nix/store/d7p...86s-status-mobile-clojure-deps/cljfmt/cljfmt/0.6.7/cljfmt-0.6.7.pom
/nix/store/d7p...86s-status-mobile-clojure-deps/cljfmt/cljfmt/0.6.7/cljfmt-0.6.7.jar.sha1
/nix/store/d7p...86s-status-mobile-clojure-deps/cljfmt/cljfmt/0.6.7/cljfmt-0.6.7.jar