crane icon indicating copy to clipboard operation
crane copied to clipboard

Way to get the binary for `cargo-test/cargo-nextest`

Open guskovd opened this issue 1 year ago • 2 comments

Way to get the binary for cargo-test/cargo-nextest

For some reason, I would like to run tests not at the time of building the application, but after

For example, this can be useful when running integration tests

Therefore, I would like to understand whether such binaries can be assembled using crane?

guskovd avatar Apr 30 '24 18:04 guskovd

Yeah. cargo nextest --no-run. Though I'm not sure if normal craneLib.buildPackage, would pick these binaries out of ./target. You might need to keep the target and just extract it outside of Nix or something. It's definitely doable though. Anything cargo can do directly, crane can handle too.

https://github.com/fedimint/fedimint/blob/084798db569773b61e9e0470d69ad37b2d1b548d/scripts/tests/test-ci-all.sh#L29

dpc avatar Apr 30 '24 18:04 dpc

@guskovd you can set doCheck = false; in your buildPackage derivation, and directly use craneLib.cargoTest or craneLib.cargoNextest to run the tests both of which should automatically find any test binaries compiled by cargo. Hope this helps!

ipetkov avatar May 01 '24 01:05 ipetkov