jlesquembre / clj-nix

Nix helpers for Clojure projects
https://jlesquembre.github.io/clj-nix/
Eclipse Public License 2.0
146 stars 22 forks source link

checkPhase #12

Closed Sohalt closed 2 years ago

Sohalt commented 2 years ago

It would be nice to be able to use checkPhase to run unit tests, e.g. using clojure -X:test or some other test runner. Maybe a general approach would be to pass all "unknown" attributes to mkCljBin through to mkDerivation. This is also done in a few other mkDerivation "wrappers", e.g. mkshell.

jlesquembre commented 2 years ago

Totally agree. I'm not sure about the best way to do it, but it makes a lot of sense to provide a way to run the tests in the checkPhase.

Sohalt commented 2 years ago

What do you think about my suggestion to just pass the attributes to mkDerviation? That way I could write something like

mkCljBin {
  name = "foo";
  projectSrc = ./.;
  main-ns = "foo.main";
  checkPhase = "clj -X:test";
}
jlesquembre commented 2 years ago

@Sohalt I like it, probably I'll implement it that way :+1:

But first I have to finish the work I'm doing in the local-cache branch, without those changes, specifying an alias at nix build time it's not going to work

Sohalt commented 2 years ago

Ah, I didn't know that. Thanks!

jlesquembre commented 2 years ago

Done, see an example here: https://github.com/jlesquembre/clj-nix#mkcljbin

Now you can do:

mkCljBin {
  # ...
  doCheck = true;
  checkPhase = "clj -M:test";
}
jlesquembre commented 2 years ago

@Sohalt Thanks again for pointing me to the mkshell example :)