It's quite challenging to export secondary artifacts like tests and benchmark executables. Those kind of artifacts can be very valuable for different reasons:
For final artifacts we have target/(release|debug)/{crate-name}
, but test and benchmark executables are containing
hash like target/release/deps/app-25de5d28a523d3c2
. Moreover it changes every time compiler options are changed. For
this reason methods like find
and cp
doesn't work well for extracting such artifacts.
Thankfully, compiler provide service messages (cargo build --message-format=json
) which allows to list all the
artifacts generated by the compiler.
console
$ cargo install --git=https://github.com/bazhenov/cargo-export.git
console
$ cargo export target/tests -- test
Under the hood this command will run cargo test --no-run --message-format=json
and copy all the generated binaries in
the target/tests
dirctory.