Skip to content

Commit 1ebc0ac

Browse files
committed
Disable test harness for lib target
Without this change, if `testsuite/src/lib.rs` will be crated and `cargo test` is invoked, cargo will try to link libtest with the crate. As this crate is `no_std` and will usually be run for targets, where no std library exists and therefor also no libtest, this will fail with an error similar to this: error[E0463]: can't find crate for `test` error: aborting due to previous error For more information about this error, try `rustc --explain E0463`. error: could not compile `testsuite` To circumvent this issue, disable the harness for lib as well. Because the crates lib.rs is handled as a binary for test mode, rust will look for a main function. Add a minimal lib.rs, so that it will compile and run, when test is invoked.
1 parent ec32e79 commit 1ebc0ac

2 files changed

Lines changed: 10 additions & 0 deletions

File tree

testsuite/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ publish = false
66
edition = "2018"
77
version = "0.1.0"
88

9+
[lib]
10+
harness = false
11+
912
[[test]]
1013
name = "test"
1114
harness = false

testsuite/src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#![no_std]
2+
#![cfg_attr(test, no_main)]
3+
4+
use {{crate_name}} as _; // memory layout + panic handler
5+
6+
#[defmt_test::tests]
7+
mod tests {}

0 commit comments

Comments
 (0)