From bbe1d0cd5612109ec87e3a2c8ed4ae508e90fade Mon Sep 17 00:00:00 2001 From: Vinzent Steinberg Date: Sat, 10 Apr 2021 00:48:58 -0300 Subject: [PATCH 1/3] Improve error message for `cargo test` There is a custom compiler error, hinting that the "debug", "compare" and "rand" feature are required for compiling and running the tests. However, this error was not displayed when running `cargo test` due to other compilation errors taking precedence. This is now avoided by just not compiling the integration tests when the necessary features are not enabled. --- tests/lib.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/lib.rs b/tests/lib.rs index add7a468..8ee85f07 100644 --- a/tests/lib.rs +++ b/tests/lib.rs @@ -1,8 +1,4 @@ -#[cfg(any( - not(feature = "debug"), - not(feature = "compare"), - not(feature = "rand") -))] +#[cfg(not(all(feature = "debug", feature = "compare", feature = "rand")))] compile_error!( "Please enable the `debug`, `compare`, and `rand` features in order to compile and run the tests. Example: `cargo test --features debug,compare,rand`" @@ -10,18 +6,25 @@ compile_error!( #[cfg(feature = "abomonation-serialize")] extern crate abomonation; +#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] #[macro_use] extern crate approx; extern crate nalgebra as na; extern crate num_traits as num; +#[cfg(feature = "rand")] extern crate rand_package as rand; +#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] mod core; +#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] mod geometry; +#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] mod linalg; +#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] #[cfg(feature = "proptest-support")] mod proptest; +//#[cfg(all(feature = "debug", feature = "compare", feature = "rand"))] //#[cfg(feature = "sparse")] //mod sparse; From df33dec457d57a6f910ab7c0429ecf95fc14fb13 Mon Sep 17 00:00:00 2001 From: Vinzent Steinberg Date: Sat, 10 Apr 2021 00:52:54 -0300 Subject: [PATCH 2/3] Make "compare" a required feature for the `matrixcompare` example This avoids distracting error messages when running `cargo test` and gives a better error when trying to run the example without the required feature. --- Cargo.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index d9418a88..39dbb555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -92,6 +92,10 @@ itertools = "0.10" [workspace] members = [ "nalgebra-lapack", "nalgebra-glm", "nalgebra-sparse" ] +[[example]] +name = "matrixcompare" +required-features = ["compare"] + [[bench]] name = "nalgebra_bench" harness = false From 260ee54288a70d9ff388f7c2b57539b166719c45 Mon Sep 17 00:00:00 2001 From: Vinzent Steinberg Date: Sat, 10 Apr 2021 01:00:12 -0300 Subject: [PATCH 3/3] Disable some tests if "rand" feature is disabled This avoids some misleading errors for `cargo test`. --- src/geometry/quaternion_construction.rs | 1 + src/linalg/symmetric_eigen.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/geometry/quaternion_construction.rs b/src/geometry/quaternion_construction.rs index 89911b91..50807907 100644 --- a/src/geometry/quaternion_construction.rs +++ b/src/geometry/quaternion_construction.rs @@ -891,6 +891,7 @@ where } #[cfg(test)] +#[cfg(feature = "rand")] mod tests { extern crate rand_xorshift; use super::*; diff --git a/src/linalg/symmetric_eigen.rs b/src/linalg/symmetric_eigen.rs index 64d3515a..d30c2f80 100644 --- a/src/linalg/symmetric_eigen.rs +++ b/src/linalg/symmetric_eigen.rs @@ -337,6 +337,7 @@ mod test { } } + #[cfg(feature = "rand")] #[test] fn wilkinson_shift_random() { for _ in 0..1000 {