From a4fa3f9c1b07ff20603b026b47bff3545e9931c7 Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Thu, 12 Nov 2020 11:50:32 +0100 Subject: [PATCH 1/2] Fail test compilation if mandatory features are missing --- tests/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tests/lib.rs b/tests/lib.rs index ee180666..c3ffc5d8 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,3 +1,9 @@ +#[cfg(any(not(feature = "debug"), not(feature = "compare")))] +compile_error!( + "Please enable the `debug` and `compare` features \ + in order to compile and run the tests." +); + #[cfg(feature = "abomonation-serialize")] extern crate abomonation; #[macro_use] From 93eddc21200ef6ad185e318b84b1628a7e4b9de9 Mon Sep 17 00:00:00 2001 From: Andreas Longva Date: Mon, 16 Nov 2020 14:13:17 +0100 Subject: [PATCH 2/2] Add example to compile_error message --- tests/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/lib.rs b/tests/lib.rs index c3ffc5d8..02044b97 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,7 +1,7 @@ #[cfg(any(not(feature = "debug"), not(feature = "compare")))] compile_error!( - "Please enable the `debug` and `compare` features \ - in order to compile and run the tests." + "Please enable the `debug` and `compare` features in order to compile and run the tests. + Example: `cargo test --features debug --features compare`" ); #[cfg(feature = "abomonation-serialize")]