Fix test case header parsing code in presence of multiple revisions.

The previous code would parse the TestProps, and then parse them
again with a revision set, adding some elements (like aux_builds)
a second time to the existing TestProps.
This commit is contained in:
Michael Woerister 2017-11-10 17:26:10 +01:00
parent 968b6206cb
commit 6a9fa50f4a
2 changed files with 11 additions and 10 deletions

View File

@ -259,9 +259,9 @@ impl TestProps {
props
}
pub fn from_file(testfile: &Path, config: &Config) -> Self {
pub fn from_file(testfile: &Path, cfg: Option<&str>, config: &Config) -> Self {
let mut props = TestProps::new();
props.load_from(testfile, None, config);
props.load_from(testfile, cfg, config);
props
}
@ -269,10 +269,10 @@ impl TestProps {
/// tied to a particular revision `foo` (indicated by writing
/// `//[foo]`), then the property is ignored unless `cfg` is
/// `Some("foo")`.
pub fn load_from(&mut self,
testfile: &Path,
cfg: Option<&str>,
config: &Config) {
fn load_from(&mut self,
testfile: &Path,
cfg: Option<&str>,
config: &Config) {
iter_header(testfile,
cfg,
&mut |ln| {

View File

@ -69,7 +69,7 @@ pub fn run(config: Config, testpaths: &TestPaths) {
print!("\n\n");
}
debug!("running {:?}", testpaths.file.display());
let base_props = TestProps::from_file(&testpaths.file, &config);
let base_props = TestProps::from_file(&testpaths.file, None, &config);
let base_cx = TestCx { config: &config,
props: &base_props,
@ -81,8 +81,9 @@ pub fn run(config: Config, testpaths: &TestPaths) {
base_cx.run_revision()
} else {
for revision in &base_props.revisions {
let mut revision_props = base_props.clone();
revision_props.load_from(&testpaths.file, Some(revision), &config);
let revision_props = TestProps::from_file(&testpaths.file,
Some(revision),
&config);
let rev_cx = TestCx {
config: &config,
props: &revision_props,
@ -2614,4 +2615,4 @@ fn read2_abbreviated(mut child: Child) -> io::Result<Output> {
stdout: stdout.into_bytes(),
stderr: stderr.into_bytes(),
})
}
}