mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Begin working on a ref test harness
This commit is contained in:
parent
3643c9701c
commit
4f6d4f3561
2 changed files with 74 additions and 0 deletions
23
src/reftest/rasterize.js
Normal file
23
src/reftest/rasterize.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
// 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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
51
src/reftest/reftest.rs
Normal file
51
src/reftest/reftest.rs
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
use std;
|
||||||
|
|
||||||
|
import result::{ok, err};
|
||||||
|
import std::test{test_opts, run_tests_console, test_desc};
|
||||||
|
import std::getopts::{getopts, reqopt, opt_opt, fail_str};
|
||||||
|
|
||||||
|
fn main(args: [str]) {
|
||||||
|
let config = parse_config(args);
|
||||||
|
let opts = test_options(config);
|
||||||
|
let tests = find_tests(config);
|
||||||
|
run_tests_console(opts, tests);
|
||||||
|
}
|
||||||
|
|
||||||
|
type Config = {
|
||||||
|
source_dir: str,
|
||||||
|
work_dir: str
|
||||||
|
};
|
||||||
|
|
||||||
|
fn parse_config(args: [str]) -> Config {
|
||||||
|
let args = args.tail();
|
||||||
|
let opts = [reqopt("source-dir"), reqopt("work-dir")];
|
||||||
|
let match = alt getopts(args, opts) {
|
||||||
|
ok(m) { m }
|
||||||
|
err(f) { fail fail_str(f) }
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
source_dir: opt_str(match, "source-dir"),
|
||||||
|
work_dir: opt_str(match, "work-dir"),
|
||||||
|
filter: if match.free.is_empty() {
|
||||||
|
none
|
||||||
|
} else {
|
||||||
|
some(match.head())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn test_options(config: config) -> test_opts {
|
||||||
|
{
|
||||||
|
filter: none,
|
||||||
|
run_ignored: false,
|
||||||
|
logfile: none
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn find_tests(config: config) -> [test_desc] {
|
||||||
|
fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is the script that uses phantom.js to render pages
|
||||||
|
fn rasterize_js() -> str { #include_str("rasterize.js") }
|
Loading…
Add table
Add a link
Reference in a new issue