Consistently refer to a test's revision
instead of cfg
Compiletest code sometimes refers to a test's revision as its `cfg`. This results in two different names for the same thing, one of which is ambiguous with other kinds of configuration (such as compiletest's own config). This patch replaces those occurrences of `cfg` with `revision`.
This commit is contained in:
parent
e13410225b
commit
99fb653d1d
@ -72,9 +72,9 @@ enum WhichLine {
|
||||
/// and also //~^ ERROR message one for the preceding line, and
|
||||
/// //~| ERROR message two for that same line.
|
||||
///
|
||||
/// If cfg is not None (i.e., in an incremental test), then we look
|
||||
/// for `//[X]~` instead, where `X` is the current `cfg`.
|
||||
pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<Error> {
|
||||
/// If revision is not None, then we look
|
||||
/// for `//[X]~` instead, where `X` is the current revision.
|
||||
pub fn load_errors(testfile: &Path, revision: Option<&str>) -> Vec<Error> {
|
||||
let rdr = BufReader::new(File::open(testfile).unwrap());
|
||||
|
||||
// `last_nonfollow_error` tracks the most recently seen
|
||||
@ -90,7 +90,7 @@ pub fn load_errors(testfile: &Path, cfg: Option<&str>) -> Vec<Error> {
|
||||
rdr.lines()
|
||||
.enumerate()
|
||||
.filter_map(|(line_num, line)| {
|
||||
parse_expected(last_nonfollow_error, line_num + 1, &line.unwrap(), cfg).map(
|
||||
parse_expected(last_nonfollow_error, line_num + 1, &line.unwrap(), revision).map(
|
||||
|(which, error)| {
|
||||
match which {
|
||||
FollowPrevious(_) => {}
|
||||
@ -108,24 +108,27 @@ fn parse_expected(
|
||||
last_nonfollow_error: Option<usize>,
|
||||
line_num: usize,
|
||||
line: &str,
|
||||
cfg: Option<&str>,
|
||||
test_revision: Option<&str>,
|
||||
) -> Option<(WhichLine, Error)> {
|
||||
// Matches comments like:
|
||||
// //~
|
||||
// //~|
|
||||
// //~^
|
||||
// //~^^^^^
|
||||
// //[cfg1]~
|
||||
// //[cfg1,cfg2]~^^
|
||||
// //[rev1]~
|
||||
// //[rev1,rev2]~^^
|
||||
static RE: Lazy<Regex> =
|
||||
Lazy::new(|| Regex::new(r"//(?:\[(?P<cfgs>[\w,]+)])?~(?P<adjust>\||\^*)").unwrap());
|
||||
Lazy::new(|| Regex::new(r"//(?:\[(?P<revs>[\w,]+)])?~(?P<adjust>\||\^*)").unwrap());
|
||||
|
||||
let captures = RE.captures(line)?;
|
||||
|
||||
match (cfg, captures.name("cfgs")) {
|
||||
// Only error messages that contain our `cfg` between the square brackets apply to us.
|
||||
(Some(cfg), Some(filter)) if !filter.as_str().split(',').any(|s| s == cfg) => return None,
|
||||
(Some(_), Some(_)) => {}
|
||||
match (test_revision, captures.name("revs")) {
|
||||
// Only error messages that contain our revision between the square brackets apply to us.
|
||||
(Some(test_revision), Some(revision_filters)) => {
|
||||
if !revision_filters.as_str().split(',').any(|r| r == test_revision) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
(None, Some(_)) => panic!("Only tests with revisions should use `//[X]~`"),
|
||||
|
||||
|
@ -289,20 +289,20 @@ impl TestProps {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_aux_file(&self, testfile: &Path, cfg: Option<&str>, config: &Config) -> Self {
|
||||
pub fn from_aux_file(&self, testfile: &Path, revision: Option<&str>, config: &Config) -> Self {
|
||||
let mut props = TestProps::new();
|
||||
|
||||
// copy over select properties to the aux build:
|
||||
props.incremental_dir = self.incremental_dir.clone();
|
||||
props.ignore_pass = true;
|
||||
props.load_from(testfile, cfg, config);
|
||||
props.load_from(testfile, revision, config);
|
||||
|
||||
props
|
||||
}
|
||||
|
||||
pub fn from_file(testfile: &Path, cfg: Option<&str>, config: &Config) -> Self {
|
||||
pub fn from_file(testfile: &Path, revision: Option<&str>, config: &Config) -> Self {
|
||||
let mut props = TestProps::new();
|
||||
props.load_from(testfile, cfg, config);
|
||||
props.load_from(testfile, revision, config);
|
||||
|
||||
match (props.pass_mode, props.fail_mode) {
|
||||
(None, None) if config.mode == Mode::Ui => props.fail_mode = Some(FailMode::Check),
|
||||
@ -315,9 +315,9 @@ impl TestProps {
|
||||
|
||||
/// Loads properties from `testfile` into `props`. If a property is
|
||||
/// tied to a particular revision `foo` (indicated by writing
|
||||
/// `//[foo]`), then the property is ignored unless `cfg` is
|
||||
/// `//@[foo]`), then the property is ignored unless `test_revision` is
|
||||
/// `Some("foo")`.
|
||||
fn load_from(&mut self, testfile: &Path, cfg: Option<&str>, config: &Config) {
|
||||
fn load_from(&mut self, testfile: &Path, test_revision: Option<&str>, config: &Config) {
|
||||
let mut has_edition = false;
|
||||
if !testfile.is_dir() {
|
||||
let file = File::open(testfile).unwrap();
|
||||
@ -331,7 +331,7 @@ impl TestProps {
|
||||
testfile,
|
||||
file,
|
||||
&mut |HeaderLine { header_revision, directive: ln, .. }| {
|
||||
if header_revision.is_some() && header_revision != cfg {
|
||||
if header_revision.is_some() && header_revision != test_revision {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -455,7 +455,7 @@ impl TestProps {
|
||||
&mut self.check_test_line_numbers_match,
|
||||
);
|
||||
|
||||
self.update_pass_mode(ln, cfg, config);
|
||||
self.update_pass_mode(ln, test_revision, config);
|
||||
self.update_fail_mode(ln, config);
|
||||
|
||||
config.set_name_directive(ln, IGNORE_PASS, &mut self.ignore_pass);
|
||||
@ -645,7 +645,7 @@ impl TestProps {
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract a `(Option<line_config>, directive)` directive from a line if comment is present.
|
||||
/// Extract an `(Option<line_revision>, directive)` directive from a line if comment is present.
|
||||
///
|
||||
/// See [`HeaderLine`] for a diagram.
|
||||
pub fn line_directive<'line>(
|
||||
@ -664,8 +664,8 @@ pub fn line_directive<'line>(
|
||||
);
|
||||
};
|
||||
|
||||
let lncfg = &ln[1..close_brace];
|
||||
Some((Some(lncfg), ln[(close_brace + 1)..].trim_start()))
|
||||
let line_revision = &ln[1..close_brace];
|
||||
Some((Some(line_revision), ln[(close_brace + 1)..].trim_start()))
|
||||
} else {
|
||||
Some((None, ln))
|
||||
}
|
||||
@ -1176,7 +1176,7 @@ pub fn make_test_description<R: Read>(
|
||||
name: test::TestName,
|
||||
path: &Path,
|
||||
src: R,
|
||||
cfg: Option<&str>,
|
||||
test_revision: Option<&str>,
|
||||
poisoned: &mut bool,
|
||||
) -> test::TestDesc {
|
||||
let mut ignore = false;
|
||||
@ -1192,7 +1192,7 @@ pub fn make_test_description<R: Read>(
|
||||
path,
|
||||
src,
|
||||
&mut |HeaderLine { header_revision, original_line, directive: ln, line_number }| {
|
||||
if header_revision.is_some() && header_revision != cfg {
|
||||
if header_revision.is_some() && header_revision != test_revision {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -10,12 +10,19 @@ fn make_test_description<R: Read>(
|
||||
name: test::TestName,
|
||||
path: &Path,
|
||||
src: R,
|
||||
cfg: Option<&str>,
|
||||
revision: Option<&str>,
|
||||
) -> test::TestDesc {
|
||||
let cache = HeadersCache::load(config);
|
||||
let mut poisoned = false;
|
||||
let test =
|
||||
crate::header::make_test_description(config, &cache, name, path, src, cfg, &mut poisoned);
|
||||
let test = crate::header::make_test_description(
|
||||
config,
|
||||
&cache,
|
||||
name,
|
||||
path,
|
||||
src,
|
||||
revision,
|
||||
&mut poisoned,
|
||||
);
|
||||
if poisoned {
|
||||
panic!("poisoned!");
|
||||
}
|
||||
|
@ -745,7 +745,7 @@ fn make_test(
|
||||
let revisions = if early_props.revisions.is_empty() || config.mode == Mode::Incremental {
|
||||
vec![None]
|
||||
} else {
|
||||
early_props.revisions.iter().map(Some).collect()
|
||||
early_props.revisions.iter().map(|r| Some(r.as_str())).collect()
|
||||
};
|
||||
|
||||
revisions
|
||||
@ -753,20 +753,13 @@ fn make_test(
|
||||
.map(|revision| {
|
||||
let src_file =
|
||||
std::fs::File::open(&test_path).expect("open test file to parse ignores");
|
||||
let cfg = revision.map(|v| &**v);
|
||||
let test_name = crate::make_test_name(&config, testpaths, revision);
|
||||
let mut desc = make_test_description(
|
||||
&config, cache, test_name, &test_path, src_file, cfg, poisoned,
|
||||
&config, cache, test_name, &test_path, src_file, revision, poisoned,
|
||||
);
|
||||
// Ignore tests that already run and are up to date with respect to inputs.
|
||||
if !config.force_rerun {
|
||||
desc.ignore |= is_up_to_date(
|
||||
&config,
|
||||
testpaths,
|
||||
&early_props,
|
||||
revision.map(|s| s.as_str()),
|
||||
inputs,
|
||||
);
|
||||
desc.ignore |= is_up_to_date(&config, testpaths, &early_props, revision, inputs);
|
||||
}
|
||||
test::TestDescAndFn {
|
||||
desc,
|
||||
@ -879,7 +872,7 @@ impl Stamp {
|
||||
fn make_test_name(
|
||||
config: &Config,
|
||||
testpaths: &TestPaths,
|
||||
revision: Option<&String>,
|
||||
revision: Option<&str>,
|
||||
) -> test::TestName {
|
||||
// Print the name of the file, relative to the repository root.
|
||||
// `src_base` looks like `/path/to/rust/tests/ui`
|
||||
@ -907,11 +900,11 @@ fn make_test_name(
|
||||
fn make_test_closure(
|
||||
config: Arc<Config>,
|
||||
testpaths: &TestPaths,
|
||||
revision: Option<&String>,
|
||||
revision: Option<&str>,
|
||||
) -> test::TestFn {
|
||||
let config = config.clone();
|
||||
let testpaths = testpaths.clone();
|
||||
let revision = revision.cloned();
|
||||
let revision = revision.map(str::to_owned);
|
||||
test::DynTestFn(Box::new(move || {
|
||||
runtest::run(config, &testpaths, revision.as_deref());
|
||||
Ok(())
|
||||
|
Loading…
x
Reference in New Issue
Block a user