Bug 1443853 - Rename RunnerProcess::is_running() to ::running(). r?jgraham draft
authorAndreas Tolfsen <ato@sny.no>
Wed, 07 Mar 2018 21:23:57 +0000
changeset 764556 60e1d60487f0aa3eb812fe64c34354235f128e02
parent 764555 3126677ed8c550fe954ec22bc37b89a83af7714d
child 764557 b00c5c6f99c5da1f330b1716f75eaf6eee70f3b3
push id101788
push userbmo:ato@sny.no
push dateWed, 07 Mar 2018 22:04:21 +0000
reviewersjgraham
bugs1443853
milestone60.0a1
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
testing/geckodriver/src/marionette.rs
testing/mozbase/rust/mozrunner/src/runner.rs
--- 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()
     }
 }