Hello.
I would like to run my unit tests (and maybe integration tests) using a command like ./mybinary --unit-tests or --integration-tests. Do you know a way to achieve this?
I’m aware of cargo test --no-run, but it produces outputs like this: target/aarch64-unknown-linux-musl/release/deps/citadel-3571420c36fb2b8, which changes every time and is hard to embed in a pipeline.
You can parse the output of cargo test --no-run --message-format=json
to get the paths to the test executables.
1 Like
Thanks for the answer - I found a way to do it a bit differently. Here's what I did:
config.linux-musl.toml
[target.aarch64-unknown-linux-musl]
linker = "compilers/cc-aarch64-linux-musl"
rustflags = ["-C", "link-self-contained=no", "-C", "target-feature=+crt-static"]
runner = "runners/aarch64-linux"
runners/aarch64-linux
#!/bin/sh
set -e
podman run \
--platform linux/arm64 \
--rm \
--security-opt label=disable \
-v $PWD/target/:$PWD/target/ \
-w $PWD \
busybox \
/bin/sh -c 'exec "$@"' sh "$@"
cargo test --config .cargo/config.linux-musl.toml --frozen --release --target aarch64-unknown-linux-musl