Merge pull request #3116 from Ms2ger/format-reftests

Cleanup formatting in reftest.rs; r=jack
This commit is contained in:
Ms2ger 2014-08-19 21:06:35 +02:00
commit 024ae42dad

View file

@ -93,13 +93,9 @@ fn parse_lists(file: &String, servo_args: &[String], render_mode: RenderMode) ->
let mut tests = Vec::new();
let mut next_id = 0;
let file_path = Path::new(file.clone());
let contents: String = match File::open_mode(&file_path, io::Open, io::Read)
.and_then(|mut f| {
f.read_to_string()
}) {
Ok(s) => s,
_ => fail!("Could not read file"),
};
let contents = File::open_mode(&file_path, io::Open, io::Read)
.and_then(|mut f| f.read_to_string())
.ok().expect("Could not read file");
for line in contents.as_slice().lines() {
// ignore comments or empty lines
@ -110,25 +106,19 @@ fn parse_lists(file: &String, servo_args: &[String], render_mode: RenderMode) ->
let parts: Vec<&str> = line.split(' ').filter(|p| !p.is_empty()).collect();
let test_line = match parts.len() {
3 => {
TestLine {
3 => TestLine {
conditions: "",
kind: parts[0],
file_left: parts[1],
file_right: parts[2],
}
},
4 => {
TestLine {
4 => TestLine {
conditions: parts[0],
kind: parts[1],
file_left: parts[2],
file_right: parts[3],
}
},
_ => {
fail!("reftest line: '{:s}' doesn't match '[CONDITIONS] KIND LEFT RIGHT'", line);
}
_ => fail!("reftest line: '{:s}' doesn't match '[CONDITIONS] KIND LEFT RIGHT'", line),
};
let kind = match test_line.kind {
@ -145,13 +135,9 @@ fn parse_lists(file: &String, servo_args: &[String], render_mode: RenderMode) ->
let mut flakiness = 0;
for condition in conditions_list {
match condition {
"flaky_cpu" => {
flakiness |= CpuRendering as uint;
},
"flaky_gpu" => {
flakiness |= GpuRendering as uint;
},
_ => {}
"flaky_cpu" => flakiness |= CpuRendering as uint,
"flaky_gpu" => flakiness |= GpuRendering as uint,
_ => (),
}
}
@ -208,7 +194,7 @@ fn check_reftest(reftest: Reftest) {
let left = capture(&reftest, 0);
let right = capture(&reftest, 1);
let pixels: Vec<u8> = left.pixels.iter().zip(right.pixels.iter()).map(|(&a, &b)| {
let pixels = left.pixels.iter().zip(right.pixels.iter()).map(|(&a, &b)| {
if a as i8 - b as i8 == 0 {
// White for correct
0xFF
@ -219,7 +205,7 @@ fn check_reftest(reftest: Reftest) {
// scaling but does not require reconstructing the actual RGBA pixel.
0xC0
}
}).collect();
}).collect::<Vec<u8>>();
let test_is_flaky = (reftest.render_mode as uint & reftest.flakiness) != 0;