diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2020-12-12 19:18:44 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2020-12-12 19:18:44 +0300 |
| commit | ec09616078e89deab5f97e578b3400b045c09575 (patch) | |
| tree | 902dcbbdbb0f59b506f50ffe704645a8870d9f76 | |
| parent | 3f2088aa603d2cd3f43c20795872de9cd6ec7735 (diff) | |
| download | rust-ec09616078e89deab5f97e578b3400b045c09575.tar.gz rust-ec09616078e89deab5f97e578b3400b045c09575.zip | |
tidy: Re-enable check for inline unit tests
| -rw-r--r-- | compiler/rustc_feature/src/lib.rs | 30 | ||||
| -rw-r--r-- | compiler/rustc_feature/src/tests.rs | 23 | ||||
| -rw-r--r-- | src/tools/tidy/src/main.rs | 5 |
3 files changed, 30 insertions, 28 deletions
diff --git a/compiler/rustc_feature/src/lib.rs b/compiler/rustc_feature/src/lib.rs index f965f7fdefe..2a7c2a02fba 100644 --- a/compiler/rustc_feature/src/lib.rs +++ b/compiler/rustc_feature/src/lib.rs @@ -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; @@ -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)); - } -} diff --git a/compiler/rustc_feature/src/tests.rs b/compiler/rustc_feature/src/tests.rs new file mode 100644 index 00000000000..50433e44b13 --- /dev/null +++ b/compiler/rustc_feature/src/tests.rs @@ -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)); +} diff --git a/src/tools/tidy/src/main.rs b/src/tools/tidy/src/main.rs index e1525f8e1bf..080e1631624 100644 --- a/src/tools/tidy/src/main.rs +++ b/src/tools/tidy/src/main.rs @@ -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); |
