Bug 1388251 - Vendor in mozrunner 0.5.0.
MozReview-Commit-ID: 3jTHzlZHRa9
--- 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":"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
+{"files":{".cargo-ok":"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855","Cargo.toml":"657202ea8600feffb50bf5c1e157a3cb7ddbfaabce8ff4fadb4dfc6bbdcd2663","LICENSE":"fab3dd6bdab226f1c08630b1dd917e11fcb4ec5e1e020e2c16f83a0a13863e85","src/bin/firefox-default-path.rs":"21f1aa96a4ffb368a4266e294bc4b1b17ff8229f2418af6679783f6d9c0280df","src/lib.rs":"26ea358c4bc1d45eb3b5ebc702b1a6bffdf5642acab9bbeffddb5be55ddb1b07","src/runner.rs":"ca015cd994987abd6902c61f9cbcabf760e6f0c0a55b4f16aa8420ab88101eae"},"package":"8ff037ca681fa465d01c863f8b16d4a008997b35468059c06f1a4b828369600b"}
\ No newline at end of file
--- a/third_party/rust/mozrunner/Cargo.toml
+++ b/third_party/rust/mozrunner/Cargo.toml
@@ -7,17 +7,17 @@
#
# 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.2"
+version = "0.5.0"
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"
[[bin]]
name = "firefox-default-path"
[dependencies.log]
--- a/third_party/rust/mozrunner/src/runner.rs
+++ b/third_party/rust/mozrunner/src/runner.rs
@@ -7,26 +7,22 @@ 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 is_running(&mut self) -> bool;
+ fn start(&mut self) -> Result<(), RunnerError>;
+ fn status(&mut self) -> IoResult<Option<process::ExitStatus>>;
fn stop(&mut self) -> IoResult<Option<process::ExitStatus>>;
}
#[derive(Debug)]
pub enum RunnerError {
Io(IoError),
PrefReader(PrefReaderError),
}
@@ -65,22 +61,22 @@ impl From<IoError> for RunnerError {
}
impl From<PrefReaderError> for RunnerError {
fn from(value: PrefReaderError) -> RunnerError {
RunnerError::PrefReader(value)
}
}
+#[derive(Debug)]
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))
@@ -88,39 +84,24 @@ impl FirefoxRunner {
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);
- self.build_command(&mut cmd);
-
- debug!("Command {:?}", cmd);
-
- let prefs = try!(self.profile.user_prefs());
- try!(prefs.write());
-
- let process = try!(cmd.spawn());
- self.process = Some(process);
- Ok(())
- }
-
fn args(&mut self) -> &mut Vec<String> {
&mut self.args
}
fn build_command(&self, command: &mut Command) {
command
.args(&self.args[..])
.envs(&self.envs);
@@ -131,27 +112,45 @@ impl Runner for FirefoxRunner {
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 is_running(&mut self) -> bool {
+ self.process.is_some() && self.status().unwrap().is_none()
+ }
+
+ fn start(&mut self) -> Result<(), RunnerError> {
+ let mut cmd = Command::new(&self.binary);
+ self.build_command(&mut cmd);
+
+ let prefs = try!(self.profile.user_prefs());
+ try!(prefs.write());
+
+ info!("Running command: {:?}", cmd);
+ let process = try!(cmd.spawn());
+ self.process = Some(process);
+ Ok(())
+ }
+
+ fn status(&mut self) -> IoResult<Option<process::ExitStatus>> {
+ self.process.as_mut().map(|p| p.try_wait()).unwrap_or(Ok(None))
}
fn stop(&mut self) -> IoResult<Option<process::ExitStatus>> {
- if let Some(p) = self.process.as_mut() {
+ let mut retval = None;
+
+ if let Some(ref mut p) = self.process {
try!(p.kill());
- let status = try!(p.wait());
- self.ret_code = Some(status);
+ retval = Some(try!(p.wait()));
};
- Ok(self.ret_code)
+ Ok(retval)
}
}
fn parse_arg_name(arg: &str) -> Option<&str> {
let mut start = 0;
let mut end = 0;
for (i, c) in arg.chars().enumerate() {