Bug 1464995 - Document mozrunner::firefox_default_path(). r=whimboo
authorAndreas Tolfsen <ato@sny.no>
Tue, 29 May 2018 17:08:14 +0100
changeset 475583 0a4e0a2002effec8e71e3a3060eec39d41ee71ba
parent 475582 d31e89c47054194dbdc4c704f029f369277282c3
child 475584 576357318f406a7a70b9585ee5f7609b3b04a30a
push id9374
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:43:20 +0000
treeherdermozilla-beta@160e085dfb0b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerswhimboo
bugs1464995
milestone62.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 1464995 - Document mozrunner::firefox_default_path(). r=whimboo The method we use to find the Firefox binary varies from platform to platform. It can be useful to document how each of the system specific implementations are meant to work. MozReview-Commit-ID: 4SrNmlp3AdS
testing/mozbase/rust/mozrunner/src/runner.rs
--- a/testing/mozbase/rust/mozrunner/src/runner.rs
+++ b/testing/mozbase/rust/mozrunner/src/runner.rs
@@ -351,31 +351,35 @@ fn find_binary(name: &str) -> Option<Pat
     })
 }
 
 #[cfg(target_os = "linux")]
 pub mod platform {
     use super::find_binary;
     use std::path::PathBuf;
 
+    /// Searches the system path for `firefox`.
     pub fn firefox_default_path() -> Option<PathBuf> {
         find_binary("firefox")
     }
 
     pub fn arg_prefix_char(c: char) -> bool {
         c == '-'
     }
 }
 
 #[cfg(target_os = "macos")]
 pub mod platform {
     use super::find_binary;
     use std::env;
     use std::path::PathBuf;
 
+    /// Searches the system path for `firefox-bin`, then looks for
+    /// `Applications/Firefox.app/Contents/MacOS/firefox-bin` under both `/`
+    /// (system root) and the user home directory.
     pub fn firefox_default_path() -> Option<PathBuf> {
         if let Some(path) = find_binary("firefox-bin") {
             return Some(path);
         }
         let home = env::home_dir();
         for &(prefix_home, trial_path) in [
             (
                 false,
@@ -404,16 +408,19 @@ pub mod platform {
 #[cfg(target_os = "windows")]
 pub mod platform {
     use super::find_binary;
     use std::io::Error;
     use std::path::PathBuf;
     use winreg::RegKey;
     use winreg::enums::*;
 
+    /// Searches the Windows registry, then the system path for `firefox.exe`.
+    ///
+    /// It _does not_ currently check the `HKEY_CURRENT_USER` tree.
     pub fn firefox_default_path() -> Option<PathBuf> {
         let opt_path = firefox_registry_path().unwrap_or(None);
         if let Some(path) = opt_path {
             if path.exists() {
                 return Some(path);
             }
         };
         find_binary("firefox.exe")
@@ -454,16 +461,18 @@ pub mod platform {
         c == '/' || c == '-'
     }
 }
 
 #[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
 pub mod platform {
     use std::path::PathBuf;
 
+    /// Returns `None` for all other operating systems than Linux, macOS, and
+    /// Windows.
     pub fn firefox_default_path() -> Option<PathBuf> {
         None
     }
 
     pub fn arg_prefix_char(c: char) -> bool {
         c == '-'
     }
 }