Skip to content

Commit

Permalink
Auto merge of servo#764 - rlhunt:reftest-include, r=glennw
Browse files Browse the repository at this point in the history
Support reftest includes in Wrench

This commit gives Wrench the ability to include reftest manifests using `include path/to/reftest.list`.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/764)
<!-- Reviewable:end -->
  • Loading branch information
bors-servo authored Jan 25, 2017
2 parents 887e883 + a215d1b commit aee85ba
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 19 deletions.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions wrench/reftests/blend/reftest.list
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
== multiply.yaml multiply-ref.yaml
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions wrench/reftests/mask/reftest.list
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
== mask.yaml mask-ref.yaml
== nested-mask.yaml nested-mask-ref.yaml
!= mask.yaml green.yaml
7 changes: 2 additions & 5 deletions wrench/reftests/reftest.list
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
== mask.yaml mask-ref.yaml
== nested-mask.yaml nested-mask-ref.yaml
!= mask.yaml green.yaml

== multiply.yaml multiply-ref.yaml
include blend/reftest.list
include mask/reftest.list
37 changes: 23 additions & 14 deletions wrench/src/reftest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,11 @@ pub struct Reftest<'a> {
reference: &'a Path,
}

pub fn parse_reftests<F>(filename: &str, mut runner: F)
fn parse_reftests<F>(manifest: &Path, runner: &mut F)
where F: FnMut(Reftest)
{
let manifest = Path::new(filename);
let dir = manifest.parent().unwrap();
let f = File::open(manifest).unwrap();
let f = File::open(manifest).expect(&format!("couldn't open manifest: {}", manifest.display()));
let file = BufReader::new(&f);
for line in file.lines() {
let l = line.unwrap();
Expand All @@ -40,18 +39,28 @@ pub fn parse_reftests<F>(filename: &str, mut runner: F)
}

let mut items = s.split_whitespace();
let kind = match items.next() {
Some("==") => ReftestOp::Equal,
Some("!=") => ReftestOp::NotEqual,

match items.next() {
Some("include") => {
let include = dir.join(items.next().unwrap());
parse_reftests(include.as_path(), runner);
}
Some(x) => {
let kind = match x {
"==" => ReftestOp::Equal,
"!=" => ReftestOp::NotEqual,
_ => panic!("unexpected match operator"),
};
let test = dir.join(items.next().unwrap());
let reference = dir.join(items.next().unwrap());
runner(Reftest {
op: kind,
test: test.as_path(),
reference: reference.as_path(),
});
}
_ => panic!(),
};
let test = dir.join(items.next().unwrap());
let reference = dir.join(items.next().unwrap());
runner(Reftest {
op: kind,
test: test.as_path(),
reference: reference.as_path(),
});
}

}
Expand Down Expand Up @@ -94,7 +103,7 @@ pub fn run_reftests(wrench: &mut Wrench, window: &mut WindowWrapper, filename: &
let (tx, rx) = channel();
wrench.renderer.set_render_notifier(Box::new(Notifier { tx: tx }));

parse_reftests(filename, |t: Reftest| {
parse_reftests(Path::new(filename), &mut |t: Reftest| {
println!("{} {}", t.test.display(), t.reference.display());
let test = render_yaml(wrench, window, t.test, &rx);
let reference = render_yaml(wrench, window, t.reference, &rx);
Expand Down

0 comments on commit aee85ba

Please sign in to comment.