Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(z-flags): Verify -Z flags list is sorted #12224

Merged
merged 1 commit into from
Jun 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/cargo/core/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
weihanglo marked this conversation as resolved.
Show resolved Hide resolved
"\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)),*])
);
}
}
}
}

Expand Down