Auto merge of #14313 - asajeffrey:util-opts-multiple-debugs, r=frewsxcv

Allow multiple -Z debug options.

<!-- Please describe your changes on the following line: -->

This PR allows the `-Z` command line option to be set multiple times; `servo -Zfoo -Zbar` is the same as `servo -Zfoo,bar`. This means we can pass debug options into `mach test-wpt` as `mach test-wpt --binary-arg=-Zfoo`; previously this failed because mach already passed in some debug options.

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes do not require tests because this is part of the debug and test architecture

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/14313)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2016-11-22 02:23:48 -06:00 committed by GitHub
commit cd77071d3f

View file

@ -350,51 +350,48 @@ pub struct DebugOptions {
impl DebugOptions { impl DebugOptions {
pub fn new(debug_string: &str) -> Result<DebugOptions, &str> { pub fn extend(&mut self, debug_string: String) -> Result<(), String> {
let mut debug_options = DebugOptions::default();
for option in debug_string.split(',') { for option in debug_string.split(',') {
match option { match option {
"help" => debug_options.help = true, "help" => self.help = true,
"bubble-widths" => debug_options.bubble_widths = true, "bubble-widths" => self.bubble_widths = true,
"disable-text-aa" => debug_options.disable_text_aa = true, "disable-text-aa" => self.disable_text_aa = true,
"enable-subpixel-aa" => debug_options.enable_subpixel_aa = true, "enable-subpixel-aa" => self.enable_subpixel_aa = true,
"disable-canvas-aa" => debug_options.disable_text_aa = true, "disable-canvas-aa" => self.disable_text_aa = true,
"dump-style-tree" => debug_options.dump_style_tree = true, "dump-style-tree" => self.dump_style_tree = true,
"dump-rule-tree" => debug_options.dump_rule_tree = true, "dump-rule-tree" => self.dump_rule_tree = true,
"dump-flow-tree" => debug_options.dump_flow_tree = true, "dump-flow-tree" => self.dump_flow_tree = true,
"dump-display-list" => debug_options.dump_display_list = true, "dump-display-list" => self.dump_display_list = true,
"dump-display-list-json" => debug_options.dump_display_list_json = true, "dump-display-list-json" => self.dump_display_list_json = true,
"dump-layer-tree" => debug_options.dump_layer_tree = true, "dump-layer-tree" => self.dump_layer_tree = true,
"relayout-event" => debug_options.relayout_event = true, "relayout-event" => self.relayout_event = true,
"profile-script-events" => debug_options.profile_script_events = true, "profile-script-events" => self.profile_script_events = true,
"profile-heartbeats" => debug_options.profile_heartbeats = true, "profile-heartbeats" => self.profile_heartbeats = true,
"show-compositor-borders" => debug_options.show_compositor_borders = true, "show-compositor-borders" => self.show_compositor_borders = true,
"show-fragment-borders" => debug_options.show_fragment_borders = true, "show-fragment-borders" => self.show_fragment_borders = true,
"show-parallel-paint" => debug_options.show_parallel_paint = true, "show-parallel-paint" => self.show_parallel_paint = true,
"show-parallel-layout" => debug_options.show_parallel_layout = true, "show-parallel-layout" => self.show_parallel_layout = true,
"paint-flashing" => debug_options.paint_flashing = true, "paint-flashing" => self.paint_flashing = true,
"trace-layout" => debug_options.trace_layout = true, "trace-layout" => self.trace_layout = true,
"disable-share-style-cache" => debug_options.disable_share_style_cache = true, "disable-share-style-cache" => self.disable_share_style_cache = true,
"style-sharing-stats" => debug_options.style_sharing_stats = true, "style-sharing-stats" => self.style_sharing_stats = true,
"convert-mouse-to-touch" => debug_options.convert_mouse_to_touch = true, "convert-mouse-to-touch" => self.convert_mouse_to_touch = true,
"replace-surrogates" => debug_options.replace_surrogates = true, "replace-surrogates" => self.replace_surrogates = true,
"gc-profile" => debug_options.gc_profile = true, "gc-profile" => self.gc_profile = true,
"load-webfonts-synchronously" => debug_options.load_webfonts_synchronously = true, "load-webfonts-synchronously" => self.load_webfonts_synchronously = true,
"disable-vsync" => debug_options.disable_vsync = true, "disable-vsync" => self.disable_vsync = true,
"wr-stats" => debug_options.webrender_stats = true, "wr-stats" => self.webrender_stats = true,
"wr-debug" => debug_options.webrender_debug = true, "wr-debug" => self.webrender_debug = true,
"wr-record" => debug_options.webrender_record = true, "wr-record" => self.webrender_record = true,
"msaa" => debug_options.use_msaa = true, "msaa" => self.use_msaa = true,
"full-backtraces" => debug_options.full_backtraces = true, "full-backtraces" => self.full_backtraces = true,
"precache-shaders" => debug_options.precache_shaders = true, "precache-shaders" => self.precache_shaders = true,
"signpost" => debug_options.signpost = true, "signpost" => self.signpost = true,
"" => {}, "" => {},
_ => return Err(option) _ => return Err(String::from(option)),
}; };
}; };
Ok(())
Ok(debug_options)
} }
} }
@ -614,7 +611,7 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
"Probability of randomly closing a pipeline (for testing constellation hardening).", "Probability of randomly closing a pipeline (for testing constellation hardening).",
"0.0"); "0.0");
opts.optopt("", "random-pipeline-closure-seed", "A fixed seed for repeatbility of random pipeline closure.", ""); opts.optopt("", "random-pipeline-closure-seed", "A fixed seed for repeatbility of random pipeline closure.", "");
opts.optopt("Z", "debug", opts.optmulti("Z", "debug",
"A comma-separated string of debug options. Pass help to show available options.", ""); "A comma-separated string of debug options. Pass help to show available options.", "");
opts.optflag("h", "help", "Print this message"); opts.optflag("h", "help", "Print this message");
opts.optopt("", "resources-path", "Path to find static resources", "/home/servo/resources"); opts.optopt("", "resources-path", "Path to find static resources", "/home/servo/resources");
@ -648,15 +645,13 @@ pub fn from_cmdline_args(args: &[String]) -> ArgumentParsingResult {
return ArgumentParsingResult::ContentProcess(content_process); return ArgumentParsingResult::ContentProcess(content_process);
} }
let debug_string = match opt_match.opt_str("Z") { let mut debug_options = DebugOptions::default();
Some(string) => string,
None => String::new()
};
let debug_options = match DebugOptions::new(&debug_string) { for debug_string in opt_match.opt_strs("Z") {
Ok(debug_options) => debug_options, if let Err(e) = debug_options.extend(debug_string) {
Err(e) => args_fail(&format!("error: unrecognized debug option: {}", e)), return args_fail(&format!("error: unrecognized debug option: {}", e));
}; }
}
if debug_options.help { if debug_options.help {
print_debug_usage(app_name) print_debug_usage(app_name)