From 8d143cc92eac7f241f9b9fe56fed2b15b50ca2cb Mon Sep 17 00:00:00 2001 From: Scott Schafer Date: Fri, 2 Jun 2023 11:29:18 -0500 Subject: [PATCH] test(z-flags): Verify `-Z` flags list is sorted --- src/cargo/core/features.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/cargo/core/features.rs b/src/cargo/core/features.rs index fa63be96eb2..e9cb7bcc0a9 100644 --- a/src/cargo/core/features.rs +++ b/src/cargo/core/features.rs @@ -687,6 +687,26 @@ macro_rules! unstable_cli_options { fields } } + + #[cfg(test)] + mod test { + #[test] + fn ensure_sorted() { + // This will be printed out if the fields are not sorted. + let location = std::panic::Location::caller(); + println!( + "\nTo fix this test, sort the features inside the macro at {}:{}\n", + location.file(), + location.line() + ); + let mut expected = vec![$(stringify!($element)),*]; + expected[2..].sort(); + snapbox::assert_eq( + format!("{:#?}", expected), + format!("{:#?}", vec![$(stringify!($element)),*]) + ); + } + } } }