Rollup merge of #32171 - frewsxcv:compiletest, r=alexcrichton
Fix a couple compiletest nits.
This commit is contained in:
commit
c194ccef13
2 changed files with 14 additions and 16 deletions
|
@ -15,7 +15,7 @@ use std::io::prelude::*;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
pub struct ExpectedError {
|
pub struct ExpectedError {
|
||||||
pub line: usize,
|
pub line_num: usize,
|
||||||
pub kind: String,
|
pub kind: String,
|
||||||
pub msg: String,
|
pub msg: String,
|
||||||
}
|
}
|
||||||
|
@ -53,15 +53,15 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<ExpectedError> {
|
||||||
|
|
||||||
rdr.lines()
|
rdr.lines()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.filter_map(|(line_no, ln)| {
|
.filter_map(|(line_num, line)| {
|
||||||
parse_expected(last_nonfollow_error,
|
parse_expected(last_nonfollow_error,
|
||||||
line_no + 1,
|
line_num + 1,
|
||||||
&ln.unwrap(),
|
&line.unwrap(),
|
||||||
&tag)
|
&tag)
|
||||||
.map(|(which, error)| {
|
.map(|(which, error)| {
|
||||||
match which {
|
match which {
|
||||||
FollowPrevious(_) => {}
|
FollowPrevious(_) => {}
|
||||||
_ => last_nonfollow_error = Some(error.line),
|
_ => last_nonfollow_error = Some(error.line_num),
|
||||||
}
|
}
|
||||||
error
|
error
|
||||||
})
|
})
|
||||||
|
@ -91,23 +91,21 @@ fn parse_expected(last_nonfollow_error: Option<usize>,
|
||||||
.skip_while(|c| !c.is_whitespace())
|
.skip_while(|c| !c.is_whitespace())
|
||||||
.collect::<String>().trim().to_owned();
|
.collect::<String>().trim().to_owned();
|
||||||
|
|
||||||
let (which, line) = if follow {
|
let (which, line_num) = if follow {
|
||||||
assert!(adjusts == 0, "use either //~| or //~^, not both.");
|
assert!(adjusts == 0, "use either //~| or //~^, not both.");
|
||||||
let line = last_nonfollow_error.unwrap_or_else(|| {
|
let line_num = last_nonfollow_error.expect("encountered //~| without \
|
||||||
panic!("encountered //~| without preceding //~^ line.")
|
preceding //~^ line.");
|
||||||
});
|
(FollowPrevious(line_num), line_num)
|
||||||
(FollowPrevious(line), line)
|
|
||||||
} else {
|
} else {
|
||||||
let which =
|
let which =
|
||||||
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
|
if adjusts > 0 { AdjustBackward(adjusts) } else { ThisLine };
|
||||||
let line = line_num - adjusts;
|
let line_num = line_num - adjusts;
|
||||||
(which, line)
|
(which, line_num)
|
||||||
};
|
};
|
||||||
|
|
||||||
debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
|
debug!("line={} tag={:?} which={:?} kind={:?} msg={:?}",
|
||||||
line_num, tag, which, kind, msg);
|
line_num, tag, which, kind, msg);
|
||||||
|
Some((which, ExpectedError { line_num: line_num,
|
||||||
Some((which, ExpectedError { line: line,
|
|
||||||
kind: kind,
|
kind: kind,
|
||||||
msg: msg, }))
|
msg: msg, }))
|
||||||
}
|
}
|
||||||
|
|
|
@ -1004,7 +1004,7 @@ fn check_expected_errors(revision: Option<&str>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let prefixes = expected_errors.iter().map(|ee| {
|
let prefixes = expected_errors.iter().map(|ee| {
|
||||||
let expected = format!("{}:{}:", testpaths.file.display(), ee.line);
|
let expected = format!("{}:{}:", testpaths.file.display(), ee.line_num);
|
||||||
// On windows just translate all '\' path separators to '/'
|
// On windows just translate all '\' path separators to '/'
|
||||||
expected.replace(r"\", "/")
|
expected.replace(r"\", "/")
|
||||||
}).collect::<Vec<String>>();
|
}).collect::<Vec<String>>();
|
||||||
|
@ -1076,7 +1076,7 @@ fn check_expected_errors(revision: Option<&str>,
|
||||||
if !flag {
|
if !flag {
|
||||||
let ee = &expected_errors[i];
|
let ee = &expected_errors[i];
|
||||||
error(revision, &format!("expected {} on line {} not found: {}",
|
error(revision, &format!("expected {} on line {} not found: {}",
|
||||||
ee.kind, ee.line, ee.msg));
|
ee.kind, ee.line_num, ee.msg));
|
||||||
not_found += 1;
|
not_found += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue