/** * @param string $lockFile * * @throws Exception */ protected function checkMaxRuntime($lockFile) { $maxRuntime = $this->config['maxRuntime']; if ($maxRuntime === null) { return; } if ($this->helper->getPlatform() === Helper::WINDOWS) { throw new Exception('"maxRuntime" is not supported on Windows'); } $runtime = $this->helper->getLockLifetime($lockFile); if ($runtime < $maxRuntime) { return; } throw new Exception("MaxRuntime of {$maxRuntime} secs exceeded! Current runtime: {$runtime} secs"); }
/** * @covers ::getLockLifetime */ public function testGetLocklifetime() { $this->helper->acquireLock($this->lockFile); $this->assertEquals(0, $this->helper->getLockLifetime($this->lockFile)); sleep(1); $this->assertEquals(1, $this->helper->getLockLifetime($this->lockFile)); sleep(1); $this->assertEquals(2, $this->helper->getLockLifetime($this->lockFile)); $this->helper->releaseLock($this->lockFile); }