mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
Make reftest build again. Still broken
This commit is contained in:
parent
381b4f376c
commit
8aec9287e3
1 changed files with 22 additions and 22 deletions
|
@ -1,10 +1,8 @@
|
||||||
use std;
|
use std;
|
||||||
use servo;
|
use servo;
|
||||||
|
|
||||||
import result::{ok, err};
|
|
||||||
import std::test::{test_opts, run_tests_console, test_desc};
|
import std::test::{test_opts, run_tests_console, test_desc};
|
||||||
import std::getopts::{getopts, reqopt, opt_str, fail_str};
|
import std::getopts::{getopts, reqopt, opt_str, fail_str};
|
||||||
import path::{connect, basename};
|
|
||||||
import os::list_dir_path;
|
import os::list_dir_path;
|
||||||
import servo::run_pipeline_png;
|
import servo::run_pipeline_png;
|
||||||
import servo::image::base::Image;
|
import servo::image::base::Image;
|
||||||
|
@ -20,24 +18,24 @@ fn main(args: ~[~str]) {
|
||||||
struct Config {
|
struct Config {
|
||||||
source_dir: ~str;
|
source_dir: ~str;
|
||||||
work_dir: ~str;
|
work_dir: ~str;
|
||||||
filter: option<~str>;
|
filter: Option<~str>;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_config(args: ~[~str]) -> Config {
|
fn parse_config(args: ~[~str]) -> Config {
|
||||||
let args = args.tail();
|
let args = args.tail();
|
||||||
let opts = ~[reqopt(~"source-dir"), reqopt(~"work-dir")];
|
let opts = ~[reqopt(~"source-dir"), reqopt(~"work-dir")];
|
||||||
let matches = match getopts(args, opts) {
|
let matches = match getopts(args, opts) {
|
||||||
ok(m) => m,
|
Ok(m) => m,
|
||||||
err(f) => fail fail_str(f)
|
Err(f) => fail fail_str(f)
|
||||||
};
|
};
|
||||||
|
|
||||||
Config {
|
Config {
|
||||||
source_dir: opt_str(matches, ~"source-dir"),
|
source_dir: opt_str(matches, ~"source-dir"),
|
||||||
work_dir: opt_str(matches, ~"work-dir"),
|
work_dir: opt_str(matches, ~"work-dir"),
|
||||||
filter: if matches.free.is_empty() {
|
filter: if matches.free.is_empty() {
|
||||||
none
|
None
|
||||||
} else {
|
} else {
|
||||||
some(matches.free.head())
|
Some(matches.free.head())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,13 +44,13 @@ fn test_options(config: Config) -> test_opts {
|
||||||
{
|
{
|
||||||
filter: config.filter,
|
filter: config.filter,
|
||||||
run_ignored: false,
|
run_ignored: false,
|
||||||
logfile: none
|
logfile: None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_tests(config: Config) -> ~[test_desc] {
|
fn find_tests(config: Config) -> ~[test_desc] {
|
||||||
let html_files = list_dir_path(config.source_dir).filter( |file| file.ends_with(".html") );
|
let html_files = list_dir_path(&Path(config.source_dir)).filter( |file| file.to_str().ends_with(".html") );
|
||||||
return html_files.map(|file| make_test(config, file) );
|
return html_files.map(|file| make_test(config, file.to_str()) );
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_test(config: Config, file: ~str) -> test_desc {
|
fn make_test(config: Config, file: ~str) -> test_desc {
|
||||||
|
@ -71,9 +69,9 @@ struct Directives {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn load_test_directives(file: ~str) -> Directives {
|
fn load_test_directives(file: ~str) -> Directives {
|
||||||
let data = match io::read_whole_file_str(file) {
|
let data = match io::read_whole_file_str(&Path(file)) {
|
||||||
result::ok(data) => data,
|
result::Ok(data) => data,
|
||||||
result::err(*) => fail #fmt("unable to load directives for %s", file)
|
result::Err(e) => fail #fmt("unable to load directives for %s: %s", file, e)
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut ignore = false;
|
let mut ignore = false;
|
||||||
|
@ -132,27 +130,29 @@ const WIDTH: uint = 800;
|
||||||
const HEIGHT: uint = 600;
|
const HEIGHT: uint = 600;
|
||||||
|
|
||||||
fn render_servo(config: Config, file: ~str) -> Image {
|
fn render_servo(config: Config, file: ~str) -> Image {
|
||||||
let infile = ~"file://" + os::make_absolute(file);
|
let infile = ~"file://" + os::make_absolute(&Path(file)).to_str();
|
||||||
let outfile = connect(config.work_dir, basename(file) + ".png");
|
let outfilename = Path(file).filename().get().to_str() + ".png";
|
||||||
|
let outfile = Path(config.work_dir).push(outfilename).to_str();
|
||||||
run_pipeline_png(infile, outfile);
|
run_pipeline_png(infile, outfile);
|
||||||
return sanitize_image(outfile);
|
return sanitize_image(outfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_ref(config: Config, file: ~str) -> Image {
|
fn render_ref(config: Config, file: ~str) -> Image {
|
||||||
let infile = file;
|
let infile = file;
|
||||||
let outfile = connect(config.work_dir, basename(file) + ".ref.png");
|
let outfilename = Path(file).filename().get().to_str() + ".png";
|
||||||
|
let outfile = Path(config.work_dir).push(outfilename);
|
||||||
// After we've generated the reference image once, we don't need
|
// After we've generated the reference image once, we don't need
|
||||||
// to keep launching Firefox
|
// to keep launching Firefox
|
||||||
if !os::path_exists(outfile) {
|
if !os::path_exists(&outfile) {
|
||||||
let rasterize_path = rasterize_path(config);
|
let rasterize_path = rasterize_path(config);
|
||||||
let prog = run::start_program("python", ~[rasterize_path, infile, outfile]);
|
let prog = run::start_program("python", ~[rasterize_path, infile, outfile.to_str()]);
|
||||||
prog.finish();
|
prog.finish();
|
||||||
}
|
}
|
||||||
return sanitize_image(outfile);
|
return sanitize_image(outfile.to_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn sanitize_image(file: ~str) -> Image {
|
fn sanitize_image(file: ~str) -> Image {
|
||||||
let buf = io::read_whole_file(file).get();
|
let buf = io::read_whole_file(&Path(file)).get();
|
||||||
let image = servo::image::base::load_from_memory(buf).get();
|
let image = servo::image::base::load_from_memory(buf).get();
|
||||||
|
|
||||||
// I don't know how to precisely control the rendered height of
|
// I don't know how to precisely control the rendered height of
|
||||||
|
@ -167,12 +167,12 @@ fn sanitize_image(file: ~str) -> Image {
|
||||||
fn install_rasterize_py(config: Config) {
|
fn install_rasterize_py(config: Config) {
|
||||||
import io::WriterUtil;
|
import io::WriterUtil;
|
||||||
let path = rasterize_path(config);
|
let path = rasterize_path(config);
|
||||||
let writer = io::file_writer(path, ~[io::Create, io::Truncate]).get();
|
let writer = io::file_writer(&Path(path), ~[io::Create, io::Truncate]).get();
|
||||||
writer.write_str(rasterize_py());
|
writer.write_str(rasterize_py());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rasterize_path(config: Config) -> ~str {
|
fn rasterize_path(config: Config) -> ~str {
|
||||||
connect(config.work_dir, ~"rasterize.py")
|
Path(config.work_dir).push(~"rasterize.py").to_str()
|
||||||
}
|
}
|
||||||
|
|
||||||
// This is the script that uses phantom.js to render pages
|
// This is the script that uses phantom.js to render pages
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue