Skip to content

Commit 8d143cc

Browse files
committed
test(z-flags): Verify -Z flags list is sorted
1 parent bdd367f commit 8d143cc

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

src/cargo/core/features.rs

+20
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,26 @@ macro_rules! unstable_cli_options {
687687
fields
688688
}
689689
}
690+
691+
#[cfg(test)]
692+
mod test {
693+
#[test]
694+
fn ensure_sorted() {
695+
// This will be printed out if the fields are not sorted.
696+
let location = std::panic::Location::caller();
697+
println!(
698+
"\nTo fix this test, sort the features inside the macro at {}:{}\n",
699+
location.file(),
700+
location.line()
701+
);
702+
let mut expected = vec![$(stringify!($element)),*];
703+
expected[2..].sort();
704+
snapbox::assert_eq(
705+
format!("{:#?}", expected),
706+
format!("{:#?}", vec![$(stringify!($element)),*])
707+
);
708+
}
709+
}
690710
}
691711
}
692712

0 commit comments

Comments
 (0)