mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Make reftest build again. Convert to WebDriver
This commit is contained in:
parent
1cfecd4ca8
commit
3a99475fc5
4 changed files with 44 additions and 50 deletions
|
@ -109,10 +109,13 @@ servo: $(SERVO_DEPS)
|
||||||
|
|
||||||
libservo.dummy: $(SERVO_DEPS)
|
libservo.dummy: $(SERVO_DEPS)
|
||||||
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ $<
|
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ $<
|
||||||
|
touch $@
|
||||||
|
|
||||||
servo-test: $(SERVO_DEPS)
|
servo-test: $(SERVO_DEPS)
|
||||||
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) --test -o $@ $<
|
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) --test -o $@ $<
|
||||||
|
|
||||||
|
reftest: src/reftest/reftest.rs libservo.dummy
|
||||||
|
$(RUSTC) $(RUSTFLAGS) $(RUSTLIBS) -o $@ $< -L .
|
||||||
|
|
||||||
# Convenient sub-project targets
|
# Convenient sub-project targets
|
||||||
|
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
// From https://code.google.com/p/phantomjs/wiki/QuickStart
|
|
||||||
|
|
||||||
var page = require('webpage').create(),
|
|
||||||
address, output, size;
|
|
||||||
|
|
||||||
if (phantom.args.length < 2 || phantom.args.length > 3) {
|
|
||||||
console.log('Usage: rasterize.js URL filename');
|
|
||||||
phantom.exit();
|
|
||||||
} else {
|
|
||||||
address = phantom.args[0];
|
|
||||||
output = phantom.args[1];
|
|
||||||
page.viewportSize = { width: 600, height: 600 };
|
|
||||||
page.open(address, function (status) {
|
|
||||||
if (status !== 'success') {
|
|
||||||
console.log('Unable to load the address!');
|
|
||||||
} else {
|
|
||||||
window.setTimeout(function () {
|
|
||||||
page.render(output);
|
|
||||||
phantom.exit();
|
|
||||||
}, 200);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
14
src/reftest/rasterize.py
Normal file
14
src/reftest/rasterize.py
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
import sys
|
||||||
|
from selenium import webdriver
|
||||||
|
|
||||||
|
input = sys.argv[1]
|
||||||
|
output = sys.argv[2]
|
||||||
|
|
||||||
|
driver = webdriver.Firefox()
|
||||||
|
|
||||||
|
driver.set_window_size(800, 600)
|
||||||
|
driver.get(file)
|
||||||
|
|
||||||
|
screenshot = driver.get_screenshot_as_file(output)
|
||||||
|
|
||||||
|
driver.quit()
|
|
@ -8,35 +8,35 @@ import path::{connect, basename};
|
||||||
import os::list_dir_path;
|
import os::list_dir_path;
|
||||||
import servo::run_pipeline_png;
|
import servo::run_pipeline_png;
|
||||||
|
|
||||||
fn main(args: [str]) {
|
fn main(args: ~[~str]) {
|
||||||
let config = parse_config(args);
|
let config = parse_config(args);
|
||||||
let opts = test_options(config);
|
let opts = test_options(config);
|
||||||
let tests = find_tests(config);
|
let tests = find_tests(config);
|
||||||
install_rasterize_js();
|
install_rasterize_py();
|
||||||
run_tests_console(opts, tests);
|
run_tests_console(opts, tests);
|
||||||
}
|
}
|
||||||
|
|
||||||
type 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 match = alt 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 {
|
||||||
source_dir: opt_str(match, "source-dir"),
|
source_dir: opt_str(matches, ~"source-dir"),
|
||||||
work_dir: opt_str(match, "work-dir"),
|
work_dir: opt_str(matches, ~"work-dir"),
|
||||||
filter: if match.free.is_empty() {
|
filter: if matches.free.is_empty() {
|
||||||
none
|
none
|
||||||
} else {
|
} else {
|
||||||
some(match.free.head())
|
some(matches.free.head())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -49,12 +49,12 @@ fn test_options(config: Config) -> test_opts {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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(config.source_dir).filter( |file| file.ends_with(".html") );
|
||||||
ret html_files.map({ |file| make_test(config, file) });
|
return html_files.map(|file| make_test(config, file) );
|
||||||
}
|
}
|
||||||
|
|
||||||
fn make_test(config: Config, file: str) -> test_desc {
|
fn make_test(config: Config, file: ~str) -> test_desc {
|
||||||
{
|
{
|
||||||
name: file,
|
name: file,
|
||||||
fn: fn~() { run_test(config, file) },
|
fn: fn~() { run_test(config, file) },
|
||||||
|
@ -63,7 +63,7 @@ fn make_test(config: Config, file: str) -> test_desc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn run_test(config: Config, file: str) {
|
fn run_test(config: Config, file: ~str) {
|
||||||
let servo_render = render_servo(config, file);
|
let servo_render = render_servo(config, file);
|
||||||
let ref_render = render_ref(config, file);
|
let ref_render = render_ref(config, file);
|
||||||
if servo_render != ref_render {
|
if servo_render != ref_render {
|
||||||
|
@ -71,20 +71,20 @@ fn run_test(config: Config, file: str) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Render = [u8];
|
type Render = ~[u8];
|
||||||
|
|
||||||
fn render_servo(config: Config, file: str) -> Render {
|
fn render_servo(config: Config, file: ~str) -> Render {
|
||||||
let infile = file;
|
let infile = file;
|
||||||
let outfile = connect(config.work_dir, basename(file) + ".png");
|
let outfile = connect(config.work_dir, basename(file) + ".png");
|
||||||
run_pipeline_png(infile, outfile);
|
run_pipeline_png(infile, outfile);
|
||||||
fail;
|
fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_ref(config: Config, file: str) -> Render {
|
fn render_ref(config: Config, file: ~str) -> Render {
|
||||||
fail
|
fail
|
||||||
}
|
}
|
||||||
|
|
||||||
fn install_rasterize_js() { }
|
fn install_rasterize_py() { }
|
||||||
|
|
||||||
// This is the script that uses phantom.js to render pages
|
// This is the script that uses phantom.js to render pages
|
||||||
fn rasterize_js() -> str { #include_str("rasterize.js") }
|
fn rasterize_py() -> ~str { #include_str("rasterize.py") }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue