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 765977 2d144822fc4cbede7481310e922477d372f009cf
parent 765976 b933ebba91040fcb33df3e566a7ee1c7fb9a3999
child 765978 3ed0b4106633426b46bfbac903bcd8fd6cf51495
push id102198
push userbmo:ato@sny.no
push dateSun, 11 Mar 2018 16:03:30 +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()
     }
 }