From c277d25506b61a34a3b28dcf4433e203ffa43284 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Wed, 26 Feb 2014 17:22:19 -0800 Subject: [PATCH 1/2] Don't crash on bad command-line arguments As amusing as it is to have servo --help die with SIGILL, it's not the best user experience :) --- src/components/main/servo.rs | 4 ++-- src/components/util/opts.rs | 25 +++++++++++++++++-------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/components/main/servo.rs b/src/components/main/servo.rs index 53071519273..a176fbb71f6 100755 --- a/src/components/main/servo.rs +++ b/src/components/main/servo.rs @@ -117,7 +117,7 @@ pub mod util; #[start] fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, proc() { - run(opts::from_cmdline_args(os::args())) + opts::from_cmdline_args(os::args()).map(run); }) } @@ -131,7 +131,7 @@ pub extern "C" fn android_start(argc: int, argv: **u8) -> int { args.push(str::raw::from_c_str(*argv.offset(i as int) as *i8)); } } - run(opts::from_cmdline_args(args)) + opts::from_cmdline_args(os::args()).map(run); }) } diff --git a/src/components/util/opts.rs b/src/components/util/opts.rs index 2f1d9777b8a..e33d5b87379 100644 --- a/src/components/util/opts.rs +++ b/src/components/util/opts.rs @@ -10,6 +10,8 @@ use azure::azure_hl::{CoreGraphicsAcceleratedBackend, Direct2DBackend, SkiaBacke use extra::getopts::groups; use std::num; use std::rt; +use std::io; +use std::os; /// Global flags for Servo, currently set on the command line. #[deriving(Clone)] @@ -59,7 +61,12 @@ fn print_usage(app: &str, opts: &[groups::OptGroup]) { println(groups::usage(message, opts)); } -pub fn from_cmdline_args(args: &[~str]) -> Opts { +fn args_fail(msg: &str) { + io::stderr().write_line(msg); + os::set_exit_status(1); +} + +pub fn from_cmdline_args(args: &[~str]) -> Option { let app_name = args[0].to_str(); let args = args.tail(); @@ -80,19 +87,21 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts { let opt_match = match groups::getopts(args, opts) { Ok(m) => m, - Err(f) => fail!(f.to_err_msg()), + Err(f) => { + args_fail(f.to_err_msg()); + return None; + } }; if opt_match.opt_present("h") || opt_match.opt_present("help") { print_usage(app_name, opts); - // TODO: how to return a null struct and let the caller know that - // it should abort? - fail!("") + return None; }; let urls = if opt_match.free.is_empty() { print_usage(app_name, opts); - fail!(~"servo asks that you provide 1 or more URLs") + args_fail("servo asks that you provide 1 or more URLs"); + return None; } else { opt_match.free.clone() }; @@ -138,7 +147,7 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts { None => num::max(rt::default_sched_threads() * 3 / 4, 1), }; - Opts { + Some(Opts { urls: urls, render_backend: render_backend, n_render_threads: n_render_threads, @@ -151,5 +160,5 @@ pub fn from_cmdline_args(args: &[~str]) -> Opts { headless: opt_match.opt_present("z"), hard_fail: opt_match.opt_present("f"), bubble_widths_separately: opt_match.opt_present("b"), - } + }) } From 2f2df093036f40541eb9200751dfded2331c4024 Mon Sep 17 00:00:00 2001 From: Keegan McAllister Date: Wed, 26 Feb 2014 17:47:51 -0800 Subject: [PATCH 2/2] Remove remnants of old reftest system Back in 2012, Brian wrote a reftest system using Firefox via Selenium to generate comparison images. This seems like a pretty cool idea, but we didn't maintain it and important pieces are now missing. Let's remove it from the working tree to avoid confusion with the current reftest system, and I'll open a ticket about revisiting this idea. One pair of old reftest files seems usable as a new reftest and that move is included in this commit. --- src/test/harness/reftest/rasterize.py | 31 ------------------ src/test/html/ref/blank.html | 5 --- src/test/html/ref/boxes.png | Bin 4112 -> 0 bytes src/test/html/ref/compute_height_width.html | 14 -------- src/test/html/ref/height_compute.html | 14 -------- src/test/html/ref/height_compute_reset.html | 15 --------- src/test/html/ref/height_width.css | 10 ------ src/test/html/ref/simple-reset.css | 1 - src/test/html/ref/square.css | 2 -- src/test/html/ref/square.html | 6 ---- src/test/html/ref/test-image.html | 12 ------- src/test/ref/basic.list | 1 + .../height_compute.html} | 14 ++++++++ .../height_compute_reset.html} | 15 +++++++++ src/test/{html => }/ref/reset.css | 0 15 files changed, 30 insertions(+), 110 deletions(-) delete mode 100644 src/test/harness/reftest/rasterize.py delete mode 100644 src/test/html/ref/blank.html delete mode 100644 src/test/html/ref/boxes.png delete mode 100644 src/test/html/ref/compute_height_width.html delete mode 100644 src/test/html/ref/height_compute.html delete mode 100644 src/test/html/ref/height_compute_reset.html delete mode 100644 src/test/html/ref/height_width.css delete mode 100644 src/test/html/ref/simple-reset.css delete mode 100644 src/test/html/ref/square.css delete mode 100644 src/test/html/ref/square.html delete mode 100644 src/test/html/ref/test-image.html rename src/test/{html/ref/height_compute.css => ref/height_compute.html} (59%) rename src/test/{html/ref/height_compute_reset.css => ref/height_compute_reset.html} (54%) rename src/test/{html => }/ref/reset.css (100%) diff --git a/src/test/harness/reftest/rasterize.py b/src/test/harness/reftest/rasterize.py deleted file mode 100644 index 44170e142a8..00000000000 --- a/src/test/harness/reftest/rasterize.py +++ /dev/null @@ -1,31 +0,0 @@ -# Copyright 2013 The Servo Project Developers. See the COPYRIGHT -# file at the top-level directory of this distribution. -# -# Licensed under the Apache License, Version 2.0 or the MIT license -# , at your -# option. This file may not be copied, modified, or distributed -# except according to those terms. - -import sys, os -from selenium import webdriver - -input = sys.argv[1] -output = sys.argv[2] - -input = os.path.abspath(input) -output = os.path.abspath(output) - -input = "file://" + input - -print input -print output - -driver = webdriver.Firefox() - -driver.set_window_size(800, 1000) -driver.get(input) - -screenshot = driver.get_screenshot_as_file(output) - -driver.quit() diff --git a/src/test/html/ref/blank.html b/src/test/html/ref/blank.html deleted file mode 100644 index eaca3f49fd1..00000000000 --- a/src/test/html/ref/blank.html +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/src/test/html/ref/boxes.png b/src/test/html/ref/boxes.png deleted file mode 100644 index 10119280ce12a01b09b7953a3855a5b0c73c48e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4112 zcmd^>c{J2}AIE=VkR?{lMu8`kf?K>lX>+F*FM@kIb&M0@DyT<~yl0RYUKrMvDI zI6Sz!-!A9!a%Dn(IjqBr)nx=D2Mn;TrjZc&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hG`s^6-8*KKQrc=OZtt82T9l=g(F zo>t}6;mzwS*cYUiK?W=7Czz+6w`zQi+$q>|8SI|F*JmavEin3)me4FjMsTbxZ*63Lx&h2ShW2 z)$xQ<#{FT8(FbYc4*+b=2M?%Jqr?LM=oJlgwaoYDv5~VZ5ikyfDb&H*2MZpI;6jsW zz*q8F7oua1gA%u+Q~fy<9B*Y=DN!u}V5Q7xf7&~IAO_fhpu_`30N{Q72L5a26O}yT zzxbHy{s|k3LjatA*@ym$&HrpoPa5Ee(}6T2K>Gqf^arBlI?#9Uzs1OJv5XP*3Ni?C zd?0rsndaZ@{O;%{R{yWrW6{|!6QQ`>#Kakz&$IXU zVBa(LW8eAi{dY!;>b*Qw0RS?8mOR=~THq&X{b89uw6?z!`)>SSZGGRn>wAC-KZ?zL TFjlkwR{;$4&g)ibJ7NC`B7UcK diff --git a/src/test/html/ref/compute_height_width.html b/src/test/html/ref/compute_height_width.html deleted file mode 100644 index 5ecbdf0330f..00000000000 --- a/src/test/html/ref/compute_height_width.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -
-
-
-
-
-
-
-
- diff --git a/src/test/html/ref/height_compute.html b/src/test/html/ref/height_compute.html deleted file mode 100644 index c1610bb4d91..00000000000 --- a/src/test/html/ref/height_compute.html +++ /dev/null @@ -1,14 +0,0 @@ - - - - - -
-
-
-
-
-
-
-
- diff --git a/src/test/html/ref/height_compute_reset.html b/src/test/html/ref/height_compute_reset.html deleted file mode 100644 index 2440844096c..00000000000 --- a/src/test/html/ref/height_compute_reset.html +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - -
-
-
-
-
-
-
-
- diff --git a/src/test/html/ref/height_width.css b/src/test/html/ref/height_width.css deleted file mode 100644 index 8e5f58aca10..00000000000 --- a/src/test/html/ref/height_width.css +++ /dev/null @@ -1,10 +0,0 @@ -div {display : inline} -div div {width : 120px} -.start {background-color : gray; height : 500px} -.whole {background-color : red; height : 100%} -.half {background-color : rgb(250, 125, 0); height : 50%} -.quarter {background-color : yellow; height : 25%} -.eighth {background-color : green; height : 12.5%} -.sixteenth {background-color : blue; height : 6.25%} -.thirtysecond {background-color : purple; height : 3.125%} - diff --git a/src/test/html/ref/simple-reset.css b/src/test/html/ref/simple-reset.css deleted file mode 100644 index 09f51257adc..00000000000 --- a/src/test/html/ref/simple-reset.css +++ /dev/null @@ -1 +0,0 @@ -body { margin: 0px } diff --git a/src/test/html/ref/square.css b/src/test/html/ref/square.css deleted file mode 100644 index f07bbe0595d..00000000000 --- a/src/test/html/ref/square.css +++ /dev/null @@ -1,2 +0,0 @@ -body {margin : 0px} -.box {background-color : green; height : 400px; width : 400px} diff --git a/src/test/html/ref/square.html b/src/test/html/ref/square.html deleted file mode 100644 index ac9ace5a979..00000000000 --- a/src/test/html/ref/square.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - -
- diff --git a/src/test/html/ref/test-image.html b/src/test/html/ref/test-image.html deleted file mode 100644 index 323f00da4eb..00000000000 --- a/src/test/html/ref/test-image.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - -test - - - - - - - diff --git a/src/test/ref/basic.list b/src/test/ref/basic.list index 661974e2996..c6713e02f90 100644 --- a/src/test/ref/basic.list +++ b/src/test/ref/basic.list @@ -35,3 +35,4 @@ == block_image.html 500x300_green.html # == simple_iframe.html simple_iframe_ref.html -- disabled due to iframe crashiness == object_element_a.html object_element_b.html +== height_compute_reset.html height_compute.html diff --git a/src/test/html/ref/height_compute.css b/src/test/ref/height_compute.html similarity index 59% rename from src/test/html/ref/height_compute.css rename to src/test/ref/height_compute.html index 9e1c7fb9679..0f017463495 100644 --- a/src/test/html/ref/height_compute.css +++ b/src/test/ref/height_compute.html @@ -1,3 +1,5 @@ + + + + +
+
+
+
+
+
+
+
+ diff --git a/src/test/html/ref/height_compute_reset.css b/src/test/ref/height_compute_reset.html similarity index 54% rename from src/test/html/ref/height_compute_reset.css rename to src/test/ref/height_compute_reset.html index 41031e2a517..114e7ef97c2 100644 --- a/src/test/html/ref/height_compute_reset.css +++ b/src/test/ref/height_compute_reset.html @@ -1,3 +1,6 @@ + + + + + +
+
+
+
+
+
+
+
+ diff --git a/src/test/html/ref/reset.css b/src/test/ref/reset.css similarity index 100% rename from src/test/html/ref/reset.css rename to src/test/ref/reset.css