From 4f6d4f3561e8c8e650b02fada20db68650308013 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Mon, 25 Jun 2012 22:45:15 -0700 Subject: [PATCH] Begin working on a ref test harness --- src/reftest/rasterize.js | 23 ++++++++++++++++++ src/reftest/reftest.rs | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 src/reftest/rasterize.js create mode 100644 src/reftest/reftest.rs diff --git a/src/reftest/rasterize.js b/src/reftest/rasterize.js new file mode 100644 index 00000000000..2a1c6bd943d --- /dev/null +++ b/src/reftest/rasterize.js @@ -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); + } + }); +} \ No newline at end of file diff --git a/src/reftest/reftest.rs b/src/reftest/reftest.rs new file mode 100644 index 00000000000..dd89e1bd52a --- /dev/null +++ b/src/reftest/reftest.rs @@ -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") }