bug 1526938: geckodriver: fix missing flag parsing errors; r=whimboo
authorAndreas Tolfsen <ato@sny.no>
Mon, 18 Feb 2019 12:48:47 +0000
changeset 520653 e37346a0237371a6d707c27d0c7c3e4bf3dbdff1
parent 520652 6ad3a665abdfbaf3ebc96213b4bd4febfa4b062f
child 520654 16aac9625fdee7452d9cfdcf06115512db3d9410
push id2032
push userffxbld-merge
push dateMon, 13 May 2019 09:36:57 +0000
treeherdermozilla-release@455c1065dcbe [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1526938
milestone67.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 1526938: geckodriver: fix missing flag parsing errors; r=whimboo Because we emit the flag parsing errors to the log, through error!(), they are subject to whether the logging subsystem is enabled. Because logging is disabled by default, no error information is currently displayed to the user. Since we cannot initialise logging implicitly due to the risk of emitting log messages the user did not request, this patch changes geckodriver to print the flag parsing errors to stderr Depends on D19429 Differential Revision: https://phabricator.services.mozilla.com/D19430
testing/geckodriver/CHANGES.md
testing/geckodriver/src/main.rs
--- a/testing/geckodriver/CHANGES.md
+++ b/testing/geckodriver/CHANGES.md
@@ -10,16 +10,23 @@ Unreleased
 ### Removed
 
 - Removed `--webdriver-port` command-line option
 
   `--webdriver-port <PORT>` was an undocumented alias for `--port`,
   initially used for backwards compatibility with clients
   prior to Selenium 3.0.0.
 
+### Fixed
+
+- Errors related to incorrect command-line usage no longer hidden
+
+  By mistake, earlier versions of geckodriver failed to print incorrect
+  flag use.  With this release problems are again written to stderr.
+
 
 0.24.0 (2019-01-28, `917474f3473e`)
 -----------------------------------
 
 ### Added
 
 - Introduces `strictFileInteractability` capability
 
--- a/testing/geckodriver/src/main.rs
+++ b/testing/geckodriver/src/main.rs
@@ -15,16 +15,17 @@ extern crate serde_derive;
 extern crate serde_json;
 extern crate uuid;
 extern crate webdriver;
 extern crate zip;
 
 #[macro_use]
 extern crate log;
 
+use std::env;
 use std::fmt;
 use std::io::{self, Write};
 use std::net::{IpAddr, SocketAddr};
 use std::path::PathBuf;
 use std::result;
 use std::str::FromStr;
 
 use clap::{App, Arg};
@@ -244,25 +245,29 @@ fn run() -> ProgramResult<()> {
     Ok(())
 }
 
 fn main() {
     let exit_code = match run() {
         Ok(_) => EXIT_SUCCESS,
 
         Err(e) => {
-            error!("{}", e);
+            eprintln!("{}: {}", get_program_name(), e);
             e.exit_code()
         }
     };
 
     std::io::stdout().flush().unwrap();
     std::process::exit(exit_code);
 }
 
+fn get_program_name() -> String {
+    env::args().next().unwrap()
+}
+
 fn print_version() {
     println!("geckodriver {}", build::BuildInfo);
     println!("");
     println!("The source code of this program is available from");
     println!("testing/geckodriver in https://hg.mozilla.org/mozilla-central.");
     println!("");
     println!("This program is subject to the terms of the Mozilla Public License 2.0.");
     println!("You can obtain a copy of the license at https://mozilla.org/MPL/2.0/.");