Skip to content

Commit fefed13

Browse files
Support test header directives in run-make mode too.
1 parent d58ab3d commit fefed13

File tree

2 files changed

+22
-7
lines changed

2 files changed

+22
-7
lines changed

src/tools/compiletest/src/header.rs

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,15 @@ fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut FnMut(&str)) {
419419
if testfile.is_dir() {
420420
return;
421421
}
422+
423+
let comment = if testfile.to_string_lossy().ends_with(".rs") {
424+
"//"
425+
} else {
426+
"#"
427+
};
428+
429+
let comment_with_brace = comment.to_string() + "[";
430+
422431
let rdr = BufReader::new(File::open(testfile).unwrap());
423432
for ln in rdr.lines() {
424433
// Assume that any directives will be found before the first
@@ -428,10 +437,11 @@ fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut FnMut(&str)) {
428437
let ln = ln.trim();
429438
if ln.starts_with("fn") || ln.starts_with("mod") {
430439
return;
431-
} else if ln.starts_with("//[") {
440+
} else if ln.starts_with(&comment_with_brace) {
432441
// A comment like `//[foo]` is specific to revision `foo`
433442
if let Some(close_brace) = ln.find(']') {
434-
let lncfg = &ln[3..close_brace];
443+
let open_brace = ln.find('[').unwrap();
444+
let lncfg = &ln[open_brace + 1 .. close_brace];
435445
let matches = match cfg {
436446
Some(s) => s == &lncfg[..],
437447
None => false,
@@ -440,11 +450,11 @@ fn iter_header(testfile: &Path, cfg: Option<&str>, it: &mut FnMut(&str)) {
440450
it(ln[(close_brace + 1) ..].trim_left());
441451
}
442452
} else {
443-
panic!("malformed condition directive: expected `//[foo]`, found `{}`",
444-
ln)
453+
panic!("malformed condition directive: expected `{}foo]`, found `{}`",
454+
comment_with_brace, ln)
445455
}
446-
} else if ln.starts_with("//") {
447-
it(ln[2..].trim_left());
456+
} else if ln.starts_with(comment) {
457+
it(ln[comment.len() ..].trim_left());
448458
}
449459
}
450460
return;

src/tools/compiletest/src/main.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,12 @@ pub fn is_test(file_name: &OsString) -> bool {
610610
}
611611

612612
pub fn make_test(config: &Config, testpaths: &TestPaths) -> test::TestDescAndFn {
613-
let early_props = EarlyProps::from_file(config, &testpaths.file);
613+
614+
let early_props = if config.mode == Mode::RunMake {
615+
EarlyProps::from_file(config, &testpaths.file.join("Makefile"))
616+
} else {
617+
EarlyProps::from_file(config, &testpaths.file)
618+
};
614619

615620
// The `should-fail` annotation doesn't apply to pretty tests,
616621
// since we run the pretty printer across all tests by default.

0 commit comments

Comments
 (0)