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.
This commit is contained in:
Fabian Viöl
2021-06-06 16:10:08 +02:00
parent ec32e79165
commit 1ebc0ac43f
2 changed files with 10 additions and 0 deletions
+3
View File
@@ -6,6 +6,9 @@ publish = false
edition = "2018" edition = "2018"
version = "0.1.0" version = "0.1.0"
[lib]
harness = false
[[test]] [[test]]
name = "test" name = "test"
harness = false harness = false
+7
View File
@@ -0,0 +1,7 @@
#![no_std]
#![cfg_attr(test, no_main)]
use {{crate_name}} as _; // memory layout + panic handler
#[defmt_test::tests]
mod tests {}