Bug 1498247 - Part 3 - switch from using the deprecated env::home_dir() to the dirs crate; r=jgraham
authorAlex Gaynor <agaynor@mozilla.com>
Fri, 12 Oct 2018 17:26:21 +0000
changeset 489387 1122d74466326f6389e3728d9bf883af73303770
parent 489386 67a1e43538ab4632df396a80a4058f7d68d0cb79
child 489388 4e01769b6baf126a8f70713291e03592a090a379
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersjgraham
bugs1498247
milestone64.0a1
Bug 1498247 - Part 3 - switch from using the deprecated env::home_dir() to the dirs crate; r=jgraham Depends on D8578 Differential Revision: https://phabricator.services.mozilla.com/D8579
testing/mozbase/rust/mozrunner/src/lib.rs
testing/mozbase/rust/mozrunner/src/runner.rs
--- a/testing/mozbase/rust/mozrunner/src/lib.rs
+++ b/testing/mozbase/rust/mozrunner/src/lib.rs
@@ -1,11 +1,13 @@
 #[macro_use]
 extern crate log;
 extern crate mozprofile;
 #[cfg(target_os = "windows")]
 extern crate winreg;
+#[cfg(target_os = "macos")]
+extern crate dirs;
 
 pub mod firefox_args;
 pub mod path;
 pub mod runner;
 
 pub use runner::platform::firefox_default_path;
--- a/testing/mozbase/rust/mozrunner/src/runner.rs
+++ b/testing/mozbase/rust/mozrunner/src/runner.rs
@@ -306,28 +306,28 @@ pub mod platform {
     pub fn arg_prefix_char(c: char) -> bool {
         c == '-'
     }
 }
 
 #[cfg(target_os = "macos")]
 pub mod platform {
     use path::{find_binary, is_binary};
-    use std::env;
     use std::path::PathBuf;
+    use dirs;
 
     /// 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();
+        let home = dirs::home_dir();
         for &(prefix_home, trial_path) in [
             (
                 false,
                 "/Applications/Firefox.app/Contents/MacOS/firefox-bin",
             ),
             (true, "Applications/Firefox.app/Contents/MacOS/firefox-bin"),
         ].iter()
         {