mirror of
https://github.com/servo/servo.git
synced 2025-08-09 23:45:35 +01:00
Merge pull request #3116 from Ms2ger/format-reftests
Cleanup formatting in reftest.rs; r=jack
This commit is contained in:
commit
024ae42dad
1 changed files with 79 additions and 93 deletions
|
@ -93,13 +93,9 @@ fn parse_lists(file: &String, servo_args: &[String], render_mode: RenderMode) ->
|
||||||
let mut tests = Vec::new();
|
let mut tests = Vec::new();
|
||||||
let mut next_id = 0;
|
let mut next_id = 0;
|
||||||
let file_path = Path::new(file.clone());
|
let file_path = Path::new(file.clone());
|
||||||
let contents: String = match File::open_mode(&file_path, io::Open, io::Read)
|
let contents = File::open_mode(&file_path, io::Open, io::Read)
|
||||||
.and_then(|mut f| {
|
.and_then(|mut f| f.read_to_string())
|
||||||
f.read_to_string()
|
.ok().expect("Could not read file");
|
||||||
}) {
|
|
||||||
Ok(s) => s,
|
|
||||||
_ => fail!("Could not read file"),
|
|
||||||
};
|
|
||||||
|
|
||||||
for line in contents.as_slice().lines() {
|
for line in contents.as_slice().lines() {
|
||||||
// ignore comments or empty 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 parts: Vec<&str> = line.split(' ').filter(|p| !p.is_empty()).collect();
|
||||||
|
|
||||||
let test_line = match parts.len() {
|
let test_line = match parts.len() {
|
||||||
3 => {
|
3 => TestLine {
|
||||||
TestLine {
|
|
||||||
conditions: "",
|
conditions: "",
|
||||||
kind: parts[0],
|
kind: parts[0],
|
||||||
file_left: parts[1],
|
file_left: parts[1],
|
||||||
file_right: parts[2],
|
file_right: parts[2],
|
||||||
}
|
|
||||||
},
|
},
|
||||||
4 => {
|
4 => TestLine {
|
||||||
TestLine {
|
|
||||||
conditions: parts[0],
|
conditions: parts[0],
|
||||||
kind: parts[1],
|
kind: parts[1],
|
||||||
file_left: parts[2],
|
file_left: parts[2],
|
||||||
file_right: parts[3],
|
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 {
|
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;
|
let mut flakiness = 0;
|
||||||
for condition in conditions_list {
|
for condition in conditions_list {
|
||||||
match condition {
|
match condition {
|
||||||
"flaky_cpu" => {
|
"flaky_cpu" => flakiness |= CpuRendering as uint,
|
||||||
flakiness |= CpuRendering as uint;
|
"flaky_gpu" => flakiness |= GpuRendering as uint,
|
||||||
},
|
_ => (),
|
||||||
"flaky_gpu" => {
|
|
||||||
flakiness |= GpuRendering as uint;
|
|
||||||
},
|
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +194,7 @@ fn check_reftest(reftest: Reftest) {
|
||||||
let left = capture(&reftest, 0);
|
let left = capture(&reftest, 0);
|
||||||
let right = capture(&reftest, 1);
|
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 {
|
if a as i8 - b as i8 == 0 {
|
||||||
// White for correct
|
// White for correct
|
||||||
0xFF
|
0xFF
|
||||||
|
@ -219,7 +205,7 @@ fn check_reftest(reftest: Reftest) {
|
||||||
// scaling but does not require reconstructing the actual RGBA pixel.
|
// scaling but does not require reconstructing the actual RGBA pixel.
|
||||||
0xC0
|
0xC0
|
||||||
}
|
}
|
||||||
}).collect();
|
}).collect::<Vec<u8>>();
|
||||||
|
|
||||||
let test_is_flaky = (reftest.render_mode as uint & reftest.flakiness) != 0;
|
let test_is_flaky = (reftest.render_mode as uint & reftest.flakiness) != 0;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue