Skip to content

Commit 3f6964e

Browse files
committed
Automatically treat test files "feature-gate-$f.rs" as gate tests for feature $f
1 parent 6795ddf commit 3f6964e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/tools/tidy/src/features.rs

+16
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ pub fn check(path: &Path, bad: &mut bool) {
124124
return;
125125
}
126126

127+
let filen_underscore = filename.replace("-","_").replace(".rs","");
128+
test_filen_gate(&filen_underscore, &mut features);
129+
127130
contents.truncate(0);
128131
t!(t!(File::open(&file), &file).read_to_string(&mut contents));
129132

@@ -214,6 +217,19 @@ fn find_attr_val<'a>(line: &'a str, attr: &str) -> Option<&'a str> {
214217
.map(|(i, j)| &line[i..j])
215218
}
216219

220+
fn test_filen_gate(filen_underscore: &str,
221+
features: &mut HashMap<String, Feature>) -> bool {
222+
if filen_underscore.starts_with("feature_gate") {
223+
for (n, f) in features.iter_mut() {
224+
if filen_underscore == format!("feature_gate_{}", n) {
225+
f.has_gate_test = true;
226+
return true;
227+
}
228+
}
229+
}
230+
return false;
231+
}
232+
217233
fn collect_lang_features(path: &Path) -> HashMap<String, Feature> {
218234
let mut contents = String::new();
219235
t!(t!(File::open(path)).read_to_string(&mut contents));

0 commit comments

Comments
 (0)