Skip to content

Commit ec09616

Browse files
committed
tidy: Re-enable check for inline unit tests
1 parent 3f2088a commit ec09616

File tree

3 files changed

+30
-28
lines changed

3 files changed

+30
-28
lines changed

Diff for: compiler/rustc_feature/src/lib.rs

+3-27
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ mod active;
1818
mod builtin_attrs;
1919
mod removed;
2020

21+
#[cfg(test)]
22+
mod tests;
23+
2124
use rustc_span::{edition::Edition, symbol::Symbol, Span};
2225
use std::fmt;
2326
use std::num::NonZeroU32;
@@ -149,30 +152,3 @@ pub use builtin_attrs::{
149152
AttributeType, BuiltinAttribute, GatedCfg, BUILTIN_ATTRIBUTES, BUILTIN_ATTRIBUTE_MAP,
150153
};
151154
pub use removed::{REMOVED_FEATURES, STABLE_REMOVED_FEATURES};
152-
153-
#[cfg(test)]
154-
mod test {
155-
use super::UnstableFeatures;
156-
157-
#[test]
158-
fn rustc_bootstrap_parsing() {
159-
let is_bootstrap = |env, krate| {
160-
std::env::set_var("RUSTC_BOOTSTRAP", env);
161-
matches!(UnstableFeatures::from_environment(krate), UnstableFeatures::Cheat)
162-
};
163-
assert!(is_bootstrap("1", None));
164-
assert!(is_bootstrap("1", Some("x")));
165-
// RUSTC_BOOTSTRAP allows specifying a specific crate
166-
assert!(is_bootstrap("x", Some("x")));
167-
// RUSTC_BOOTSTRAP allows multiple comma-delimited crates
168-
assert!(is_bootstrap("x,y,z", Some("x")));
169-
assert!(is_bootstrap("x,y,z", Some("y")));
170-
// Crate that aren't specified do not get unstable features
171-
assert!(!is_bootstrap("x", Some("a")));
172-
assert!(!is_bootstrap("x,y,z", Some("a")));
173-
assert!(!is_bootstrap("x,y,z", None));
174-
175-
// this is technically a breaking change, but there are no stability guarantees for RUSTC_BOOTSTRAP
176-
assert!(!is_bootstrap("0", None));
177-
}
178-
}

Diff for: compiler/rustc_feature/src/tests.rs

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
use super::UnstableFeatures;
2+
3+
#[test]
4+
fn rustc_bootstrap_parsing() {
5+
let is_bootstrap = |env, krate| {
6+
std::env::set_var("RUSTC_BOOTSTRAP", env);
7+
matches!(UnstableFeatures::from_environment(krate), UnstableFeatures::Cheat)
8+
};
9+
assert!(is_bootstrap("1", None));
10+
assert!(is_bootstrap("1", Some("x")));
11+
// RUSTC_BOOTSTRAP allows specifying a specific crate
12+
assert!(is_bootstrap("x", Some("x")));
13+
// RUSTC_BOOTSTRAP allows multiple comma-delimited crates
14+
assert!(is_bootstrap("x,y,z", Some("x")));
15+
assert!(is_bootstrap("x,y,z", Some("y")));
16+
// Crate that aren't specified do not get unstable features
17+
assert!(!is_bootstrap("x", Some("a")));
18+
assert!(!is_bootstrap("x,y,z", Some("a")));
19+
assert!(!is_bootstrap("x,y,z", None));
20+
21+
// this is technically a breaking change, but there are no stability guarantees for RUSTC_BOOTSTRAP
22+
assert!(!is_bootstrap("0", None));
23+
}

Diff for: src/tools/tidy/src/main.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,12 @@ fn main() {
3535

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

4039
// Checks that need to be done for both the compiler and std libraries.
40+
unit_tests::check(&src_path, &mut bad);
41+
unit_tests::check(&compiler_path, &mut bad);
42+
unit_tests::check(&library_path, &mut bad);
43+
4144
bins::check(&src_path, &output_directory, &mut bad);
4245
bins::check(&compiler_path, &output_directory, &mut bad);
4346
bins::check(&library_path, &output_directory, &mut bad);

0 commit comments

Comments
 (0)