Reputation: 1441
I'm cross-compiling a Rust bare metal application for AArch64 target and I need to run unit tests on x86_64 target (my PC).
I created the file .cargo/config
:
[build]
target = "aarch64-unknown-none"
I'd like to build for AArch64 but to run the tests for x86_64. If I change the build to x86_64-unknown-linux-gnu
then the tests compile and execute. Is there a section where I could specify this? I have to swap these manually now.
I checked cargo guide but found no reference about test configuration.
Upvotes: 8
Views: 5420
Reputation: 71
You can achieve similar functionality by creating an alias in your .cargo/config file
[alias]
test_pc = "test --target=x86_64-unknown-linux-gnu"
then, you just just call
cargo test_pc
Upvotes: 7
Reputation: 161
You cannot.
According to issue#6874, cargo doesn't have the feature to specify different target for cargo test
.
FYI: you might have another solution for this issue if you use nightly
, though I haven't made it work. The following links are about custom test framework
, the issue opener says 'the solution'.
Upvotes: 1