Bug 1464995 - Document mozrunner::firefox_default_path(). r?whimboo draft
authorAndreas Tolfsen <ato@sny.no>
Tue, 29 May 2018 17:08:14 +0100
changeset 804044 c5fe849e3f603b0a861737c2420e88de0c6778ce
parent 804003 a358755643e92f8fc55a23e3ab1fbf88695b8bf3
child 804045 9bf8df7e8459022470151b7f33d437756da0e48e
push id112293
push userbmo:ato@sny.no
push dateTue, 05 Jun 2018 13:34:59 +0000
reviewerswhimboo
bugs1464995
milestone62.0a1
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 == '-'
     }
 }