Bug 1388249 - Vendor in mozrunner 0.4.2 crate. draft
authorHenrik Skupin <mail@hskupin.info>
Wed, 23 Aug 2017 12:26:28 +0200
changeset 651231 a656c546285dc6020bb579bf37ccfce41140aeb6
parent 651230 e6869b07be427aba46593fab02dae647fe691419
child 651232 35fc235ff6edb19c68fc1eebc3399da31d843990
push id75647
push userbmo:hskupin@gmail.com
push dateWed, 23 Aug 2017 11:36:22 +0000
bugs1388249
milestone57.0a1
Bug 1388249 - Vendor in mozrunner 0.4.2 crate. MozReview-Commit-ID: DNaQKpDBQu8
third_party/rust/mozrunner/.cargo-checksum.json
third_party/rust/mozrunner/Cargo.toml
third_party/rust/mozrunner/src/runner.rs
--- a/third_party/rust/mozrunner/.cargo-checksum.json
+++ b/third_party/rust/mozrunner/.cargo-checksum.json
@@ -1,1 +1,1 @@
-{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"c9da3b2127ac20e0f3b7f87d7ee3a08a103f7893e92ee2835a3247af0389371f","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","src/bin/firefox-default-path.rs":"21f1aa96a4ffb368a4266e294bc4b1b17ff8229f2418af6679783f6d9c0280df","src/lib.rs":"26ea358c4bc1d45eb3b5ebc702b1a6bffdf5642acab9bbeffddb5be55ddb1b07","src/runner.rs":"ce33d910a0d63bb3673e159bc52f1fb4dafd9746415592f5f2bf792691f2adb2"},"package":"68e6a21ef32a737399a34d9a89640b350d8b47ef03457225c0c223842cf2311f"}
\ No newline at end of file
+{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"31f551a8237731c09c51cc0e6823e91ab09f17aa8e58b798e92fb6f2b723f589","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","src/bin/firefox-default-path.rs":"21f1aa96a4ffb368a4266e294bc4b1b17ff8229f2418af6679783f6d9c0280df","src/lib.rs":"26ea358c4bc1d45eb3b5ebc702b1a6bffdf5642acab9bbeffddb5be55ddb1b07","src/runner.rs":"c1b94da5424d06a1a233e242d0a2488895e47ed133f8456473871c5a2bb471f1"},"package":"eb9d113eaa876c004ad5119224e318b36fd358658e47cdd49b45d209b2d7ac82"}
\ No newline at end of file
--- a/third_party/rust/mozrunner/Cargo.toml
+++ b/third_party/rust/mozrunner/Cargo.toml
@@ -1,17 +1,29 @@
+# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
+#
+# When uploading crates to the registry Cargo will automatically
+# "normalize" Cargo.toml files for maximal compatibility
+# with all versions of Cargo and also rewrite `path` dependencies
+# to registry (e.g. crates.io) dependencies
+#
+# If you believe there's an error in this file please file an
+# issue against the rust-lang/cargo repository. If you're
+# editing this file be aware that the upstream Cargo.toml
+# will likely look very different (and much more reasonable)
+
 [package]
 name = "mozrunner"
-version = "0.4.1"
+version = "0.4.2"
 authors = ["Mozilla Tools and Automation <auto-tools@mozilla.com>"]
 description = "Library for starting Firefox binaries."
+license = "MPL-2.0"
 repository = "https://github.com/jgraham/rust_mozrunner"
-license = "MPL-2.0"
-
-[dependencies]
-log = "0.3"
-mozprofile = "0.3"
-
-[target.'cfg(target_os = "windows")'.dependencies]
-winreg = "0.3.5"
 
 [[bin]]
-name = "firefox-default-path"
\ No newline at end of file
+name = "firefox-default-path"
+[dependencies.log]
+version = "0.3"
+
+[dependencies.mozprofile]
+version = "0.3"
+[target."cfg(target_os = \"windows\")".dependencies.winreg]
+version = "0.3.5"
--- a/third_party/rust/mozrunner/src/runner.rs
+++ b/third_party/rust/mozrunner/src/runner.rs
@@ -1,27 +1,30 @@
 use mozprofile::prefreader::PrefReaderError;
 use mozprofile::profile::Profile;
 use std::ascii::AsciiExt;
+use std::collections::HashMap;
 use std::convert::From;
 use std::env;
 use std::error::Error;
 use std::fmt;
 use std::io::{Result as IoResult, Error as IoError, ErrorKind};
 use std::path::{Path, PathBuf};
 use std::process;
 use std::process::{Command, Stdio};
 
 pub trait Runner {
     fn start(&mut self) -> Result<(), RunnerError>;
 
     fn args(&mut self) -> &mut Vec<String>;
 
     fn build_command(&self, &mut Command);
 
+    fn envs(&mut self) -> &mut HashMap<String, String>;
+
     fn is_running(&self) -> bool;
 
     fn stop(&mut self) -> IoResult<Option<process::ExitStatus>>;
 }
 
 #[derive(Debug)]
 pub enum RunnerError {
     Io(IoError),
@@ -65,33 +68,39 @@ impl From<PrefReaderError> for RunnerErr
     fn from(value: PrefReaderError) -> RunnerError {
         RunnerError::PrefReader(value)
     }
 }
 
 pub struct FirefoxRunner {
     pub binary: PathBuf,
     args: Vec<String>,
+    envs: HashMap<String, String>,
     process: Option<process::Child>,
     pub ret_code: Option<process::ExitStatus>,
     pub profile: Profile
 }
 
 impl FirefoxRunner {
     pub fn new(binary: &Path, profile: Option<Profile>) -> IoResult<FirefoxRunner> {
         let prof = match profile {
             Some(p) => p,
             None => try!(Profile::new(None))
         };
 
+        let mut envs = HashMap::new();
+        envs.insert("MOZ_NO_REMOTE".to_string(), "1".to_string());
+        envs.insert("NO_EM_RESTART".to_string(), "1".to_string());
+
         Ok(FirefoxRunner {
             binary: binary.to_path_buf(),
             process: None,
             ret_code: None,
             args: Vec::new(),
+            envs: envs,
             profile: prof
         })
     }
 }
 
 impl Runner for FirefoxRunner {
     fn start(&mut self) -> Result<(), RunnerError> {
         let mut cmd = Command::new(&self.binary);
@@ -108,27 +117,30 @@ impl Runner for FirefoxRunner {
     }
 
     fn args(&mut self) -> &mut Vec<String> {
         &mut self.args
     }
 
     fn build_command(&self, command: &mut Command) {
         command
-            .env("MOZ_NO_REMOTE", "1")
-            .env("NO_EM_RESTART", "1")
-            .args(&self.args[..]);
+            .args(&self.args[..])
+            .envs(&self.envs);
 
         if !self.args.iter().any(|x| is_profile_arg(x)) {
             command.arg("-profile").arg(&self.profile.path);
         }
         command.stdout(Stdio::inherit())
             .stderr(Stdio::inherit());
     }
 
+    fn envs(&mut self) -> &mut HashMap<String, String> {
+        &mut self.envs
+    }
+
     fn is_running(&self) -> bool {
         self.process.is_some() && self.ret_code.is_none()
     }
 
     fn stop(&mut self) -> IoResult<Option<process::ExitStatus>> {
         if let Some(p) = self.process.as_mut() {
             try!(p.kill());
             let status = try!(p.wait());