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
--- 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 == '-'
}
}