Bug 1443853 - Rename RunnerProcess::is_running() to ::running(). r?jgraham
The ideom for getters in Rust is to not prefix them with "is_".
Setters should, however, have the "set_" prefix.
MozReview-Commit-ID: 9kXHBYGK7aL
--- a/testing/geckodriver/src/marionette.rs
+++ b/testing/geckodriver/src/marionette.rs
@@ -597,17 +597,17 @@ impl WebDriverHandler<GeckoExtensionRout
let _ = self.handle_command(session, delete_session);
if let Some(ref mut runner) = self.browser {
let timeout = TIMEOUT_BROWSER_SHUTDOWN;
let poll_interval = 100;
let poll_attempts = timeout / poll_interval;
let mut poll_attempt = 0;
- while runner.is_running() {
+ while runner.running() {
if poll_attempt <= poll_attempts {
debug!("Waiting for the browser process to shutdown");
poll_attempt += 1;
sleep(Duration::from_millis(poll_interval));
} else {
warn!("Browser process did not shutdown");
break;
}
@@ -618,17 +618,17 @@ impl WebDriverHandler<GeckoExtensionRout
if let Ok(ref mut connection) = self.connection.lock() {
if let Some(conn) = connection.as_mut() {
conn.close();
}
}
// If the browser is still open then kill the process
if let Some(ref mut runner) = self.browser {
- if runner.is_running() {
+ if runner.running() {
info!("Forcing a shutdown of the browser process");
if runner.stop().is_err() {
error!("Failed to kill browser process");
};
}
}
self.connection = Mutex::new(None);
--- a/testing/mozbase/rust/mozrunner/src/runner.rs
+++ b/testing/mozbase/rust/mozrunner/src/runner.rs
@@ -43,17 +43,19 @@ pub trait Runner {
T: Into<Stdio>;
fn start(self) -> Result<Self::Process, RunnerError>;
}
pub trait RunnerProcess {
fn status(&mut self) -> IoResult<Option<process::ExitStatus>>;
fn stop(&mut self) -> IoResult<process::ExitStatus>;
- fn is_running(&mut self) -> bool;
+
+ /// Determine if the process is still running.
+ fn running(&mut self) -> bool;
}
#[derive(Debug)]
pub enum RunnerError {
Io(IoError),
PrefReader(PrefReaderError),
}
@@ -94,25 +96,25 @@ impl From<PrefReaderError> for RunnerErr
fn from(value: PrefReaderError) -> RunnerError {
RunnerError::PrefReader(value)
}
}
#[derive(Debug)]
pub struct FirefoxProcess {
process: Child,
- profile: Profile
+ profile: Profile,
}
impl RunnerProcess for FirefoxProcess {
fn status(&mut self) -> IoResult<Option<process::ExitStatus>> {
self.process.try_wait()
}
- fn is_running(&mut self) -> bool {
+ fn running(&mut self) -> bool {
self.status().unwrap().is_none()
}
fn stop(&mut self) -> IoResult<process::ExitStatus> {
self.process.kill()?;
self.process.wait()
}
}