Skip to content

tidy: Re-enable check for inline unit tests #79969

New issue

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

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

Already on GitHub? # to your account

Merged
merged 2 commits into from
Dec 12, 2020
Merged
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions compiler/rustc_expand/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,13 @@ crate mod mbe;
mod tests;
#[cfg(test)]
mod parse {
#[cfg(test)]
mod tests;
}
#[cfg(test)]
mod tokenstream {
#[cfg(test)]
mod tests;
}
#[cfg(test)]
mod mut_visit {
#[cfg(test)]
mod tests;
}
30 changes: 3 additions & 27 deletions compiler/rustc_feature/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ mod active;
mod builtin_attrs;
mod removed;

#[cfg(test)]
mod tests;

use rustc_span::{edition::Edition, symbol::Symbol, Span};
use std::fmt;
use std::num::NonZeroU32;
Expand Down Expand Up @@ -149,30 +152,3 @@ pub use builtin_attrs::{
AttributeType, BuiltinAttribute, GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
};
pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};

#[cfg(test)]
mod test {
use super::UnstableFeatures;

#[test]
fn rustc_bootstrap_parsing() {
let is_bootstrap = |env, krate| {
std::env::set_var("RUSTC_BOOTSTRAP", env);
matches!(UnstableFeatures::from_environment(krate), UnstableFeatures::Cheat)
};
assert!(is_bootstrap("1", None));
assert!(is_bootstrap("1", Some("x")));
// RUSTC_BOOTSTRAP allows specifying a specific crate
assert!(is_bootstrap("x", Some("x")));
// RUSTC_BOOTSTRAP allows multiple comma-delimited crates
assert!(is_bootstrap("x,y,z", Some("x")));
assert!(is_bootstrap("x,y,z", Some("y")));
// Crate that aren't specified do not get unstable features
assert!(!is_bootstrap("x", Some("a")));
assert!(!is_bootstrap("x,y,z", Some("a")));
assert!(!is_bootstrap("x,y,z", None));

// this is technically a breaking change, but there are no stability guarantees for RUSTC_BOOTSTRAP
assert!(!is_bootstrap("0", None));
}
}
23 changes: 23 additions & 0 deletions compiler/rustc_feature/src/tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
use super::UnstableFeatures;

#[test]
fn rustc_bootstrap_parsing() {
let is_bootstrap = |env, krate| {
std::env::set_var("RUSTC_BOOTSTRAP", env);
matches!(UnstableFeatures::from_environment(krate), UnstableFeatures::Cheat)
};
assert!(is_bootstrap("1", None));
assert!(is_bootstrap("1", Some("x")));
// RUSTC_BOOTSTRAP allows specifying a specific crate
assert!(is_bootstrap("x", Some("x")));
// RUSTC_BOOTSTRAP allows multiple comma-delimited crates
assert!(is_bootstrap("x,y,z", Some("x")));
assert!(is_bootstrap("x,y,z", Some("y")));
// Crate that aren't specified do not get unstable features
assert!(!is_bootstrap("x", Some("a")));
assert!(!is_bootstrap("x,y,z", Some("a")));
assert!(!is_bootstrap("x,y,z", None));

// this is technically a breaking change, but there are no stability guarantees for RUSTC_BOOTSTRAP
assert!(!is_bootstrap("0", None));
}
5 changes: 4 additions & 1 deletion src/tools/tidy/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ fn main() {

// Checks that only make sense for the std libs.
pal::check(&library_path, &mut bad);
unit_tests::check(&library_path, &mut bad);

// Checks that need to be done for both the compiler and std libraries.
unit_tests::check(&src_path, &mut bad);
unit_tests::check(&compiler_path, &mut bad);
unit_tests::check(&library_path, &mut bad);

bins::check(&src_path, &output_directory, &mut bad);
bins::check(&compiler_path, &output_directory, &mut bad);
bins::check(&library_path, &output_directory, &mut bad);
Expand Down