Best Atoum code snippet using builder.getRunFile
builder.php
Source:builder.php
...197 {198 $this->runFile = $path;199 return $this;200 }201 public function getRunFile()202 {203 return $this->runFile !== null ? $this->runFile : $this->adapter->sys_get_temp_dir() . \DIRECTORY_SEPARATOR . md5(get_class($this));204 }205 public function checkUnitTests()206 {207 $status = true;208 if ($this->checkUnitTests === true)209 {210 if ($this->workingDirectory === null)211 {212 throw new exceptions\logic('Unable to check unit tests, working directory is undefined');213 }214 $this->vcs215 ->setWorkingDirectory($this->workingDirectory)216 ->exportRepository()217 ;218 $this->php219 ->reset()220 ->addOption('-f', $this->workingDirectory . \DIRECTORY_SEPARATOR . $this->unitTestRunnerScript)221 ->addArgument('-ncc')222 ->addArgument('-d', $this->workingDirectory . \DIRECTORY_SEPARATOR . 'tests' . \DIRECTORY_SEPARATOR . 'units' . \DIRECTORY_SEPARATOR . 'classes')223 ->addArgument('-p', $this->php->getBinaryPath())224 ;225 $scoreFile = $this->scoreDirectory === null ? $this->adapter->tempnam($this->adapter->sys_get_temp_dir(), '') : $this->scoreDirectory . DIRECTORY_SEPARATOR . $this->vcs->getRevision();226 $this->php->addArgument('-sf', $scoreFile);227 if ($this->reportTitle !== null)228 {229 $this->php->addArgument('-drt', sprintf($this->reportTitle, '%1$s', '%2$s', '%3$s', $this->vcs->getRevision()));230 }231 foreach ($this->runnerConfigurationFiles as $runnerConfigurationFile)232 {233 $this->php->addArgument('-c', $runnerConfigurationFile);234 }235 try236 {237 $exitCode = $this->php->run()->getExitCode();238 if ($exitCode > 0)239 {240 switch ($exitCode)241 {242 case 126:243 case 127:244 throw new exceptions\runtime('Unable to find \'' . $this->php->getBinaryPath() . '\' or it is not executable');245 default:246 throw new exceptions\runtime($this->php . ' failed with exit code \'' . $exitCode . '\': ' . $this->php->getStderr());247 }248 }249 $stdErr = $this->php->getStdErr();250 if ($stdErr != '')251 {252 throw new exceptions\runtime($stdErr);253 }254 $score = @$this->adapter->file_get_contents($scoreFile);255 if ($score === false)256 {257 throw new exceptions\runtime('Unable to read score from file \'' . $scoreFile . '\'');258 }259 $score = $this->adapter->unserialize($score);260 if ($score === false)261 {262 throw new exceptions\runtime('Unable to unserialize score from file \'' . $scoreFile . '\'');263 }264 if ($score instanceof atoum\score === false)265 {266 throw new exceptions\runtime('Contents of file \'' . $scoreFile . '\' is not a score');267 }268 $status = $score->getFailNumber() === 0 && $score->getExceptionNumber() === 0 && $score->getErrorNumber() === 0;269 }270 catch (\exception $exception)271 {272 $this->writeErrorInErrorsDirectory($exception->getMessage());273 $status = false;274 }275 if ($this->scoreDirectory === null)276 {277 if ($this->adapter->unlink($scoreFile) === false)278 {279 throw new exceptions\runtime('Unable to delete score file \'' . $scoreFile . '\'');280 }281 }282 }283 return $status;284 }285 public function createPhar($version = null)286 {287 $pharBuilt = true;288 if ($this->pharCreationEnabled === true)289 {290 if ($this->destinationDirectory === null)291 {292 throw new exceptions\logic('Unable to create phar, destination directory is undefined');293 }294 if ($this->workingDirectory === null)295 {296 throw new exceptions\logic('Unable to create phar, working directory is undefined');297 }298 if ($this->revisionFile !== null)299 {300 $revision = trim(@$this->adapter->file_get_contents($this->revisionFile));301 if (is_numeric($revision) === true)302 {303 $this->vcs->setRevision($revision);304 }305 }306 $revisions = $this->vcs->getNextRevisions();307 while (sizeof($revisions) > 0)308 {309 $revision = array_shift($revisions);310 $this->vcs->setRevision($revision);311 try312 {313 if ($this->checkUnitTests() === true)314 {315 if ($this->checkUnitTests === false)316 {317 $this->vcs318 ->setWorkingDirectory($this->workingDirectory)319 ->exportRepository()320 ;321 }322 if ($this->taggerEngine !== null)323 {324 $this->taggerEngine325 ->setSrcDirectory($this->workingDirectory)326 ->setVersion($version !== null ? $version : 'nightly-' . $revision . '-' . $this->adapter->date('YmdHi'))327 ->tagVersion()328 ;329 }330 $this->php331 ->reset()332 ->addOption('-d', 'phar.readonly=0')333 ->addOption('-f', $this->workingDirectory . DIRECTORY_SEPARATOR . $this->pharGeneratorScript)334 ->addArgument('-d', $this->destinationDirectory)335 ;336 if ($this->php->run()->getExitCode() > 0)337 {338 throw new exceptions\runtime('Unable to run ' . $this->php . ': ' . $this->php->getStdErr());339 }340 }341 }342 catch (\exception $exception)343 {344 $pharBuilt = false;345 $this->writeErrorInErrorsDirectory($exception->getMessage());346 }347 if ($this->revisionFile !== null && $this->adapter->file_put_contents($this->revisionFile, $revision, \LOCK_EX) === false)348 {349 throw new exceptions\runtime('Unable to save last revision in file \'' . $this->revisionFile . '\'');350 }351 $revisions = $this->vcs->getNextRevisions();352 }353 }354 return $pharBuilt;355 }356 public function writeErrorInErrorsDirectory($error)357 {358 if ($this->errorsDirectory !== null)359 {360 $revision = $this->vcs === null ? null : $this->vcs->getRevision();361 if ($revision === null)362 {363 throw new exceptions\logic('Revision is undefined');364 }365 $errorFile = $this->errorsDirectory . \DIRECTORY_SEPARATOR . $revision;366 if ($this->adapter->file_put_contents($errorFile, $error, \LOCK_EX | \FILE_APPEND) === false)367 {368 throw new exceptions\runtime('Unable to save error in file \'' . $errorFile . '\'');369 }370 }371 return $this;372 }373 protected function includeConfigFile($path, \closure $callback = null)374 {375 if ($callback === null)376 {377 $builder = $this;378 $callback = function($path) use ($builder) { include_once($path); };379 }380 return parent::includeConfigFile($path, $callback);381 }382 protected function setArgumentHandlers()383 {384 $builder = $this;385 return parent::setArgumentHandlers()386 ->addArgumentHandler(387 function($script, $argument, $files) use ($builder) {388 if (sizeof($files) <= 0)389 {390 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));391 }392 foreach ($files as $file)393 {394 if (file_exists($file) === false)395 {396 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Runner configuration file path \'%s\' is invalid'), $file));397 }398 if (is_readable($file) === false)399 {400 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Unable to read runner configuration file \'%s\''), $file));401 }402 $script->addRunnerConfigurationFile($file);403 }404 },405 array('-rc', '--runner-configuration-files'),406 '<file>',407 $this->locale->_('Use <file> as configuration file for runner')408 )409 ->addArgumentHandler(410 function($script, $argument, $path) {411 if (sizeof($path) != 1)412 {413 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));414 }415 $script->setPhpPath(current($path));416 },417 array('-p', '--php'),418 '<path>',419 $this->locale->_('Path to PHP binary')420 )421 ->addArgumentHandler(422 function($script, $argument, $directory) {423 if (sizeof($directory) != 1)424 {425 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));426 }427 $script->setWorkingDirectory(current($directory));428 },429 array('-w', '--working-directory'),430 '<directory>',431 $this->locale->_('Checkout file from repository in <directory>')432 )433 ->addArgumentHandler(434 function($script, $argument, $directory) {435 if (sizeof($directory) != 1)436 {437 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));438 }439 $script->setDestinationDirectory(current($directory));440 },441 array('-d', '--destination-directory'),442 '<directory>',443 $this->locale->_('Save phar in <directory>')444 )445 ->addArgumentHandler(446 function($script, $argument, $directory) {447 if (sizeof($directory) != 1)448 {449 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));450 }451 $script->setScoreDirectory(current($directory));452 },453 array('-sd', '--score-directory'),454 '<directory>',455 $this->locale->_('Save score in <directory>')456 )457 ->addArgumentHandler(458 function($script, $argument, $directory) {459 if (sizeof($directory) != 1)460 {461 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));462 }463 $script->setErrorsDirectory(current($directory));464 },465 array('-ed', '--errors-directory'),466 '<directory>',467 $this->locale->_('Save errors in <directory>')468 )469 ->addArgumentHandler(470 function($script, $argument, $url) {471 if (sizeof($url) != 1)472 {473 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));474 }475 $script->getVcs()->setRepositoryUrl(current($url));476 },477 array('-r', '--repository-url'),478 '<url>',479 $this->locale->_('Url of repository')480 )481 ->addArgumentHandler(482 function($script, $argument, $file) {483 if (sizeof($file) != 1)484 {485 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));486 }487 $script->setRevisionFile(current($file));488 },489 array('-rf', '--revision-file'),490 '<file>',491 $this->locale->_('Save last revision in <file>')492 )493 ->addArgumentHandler(494 function($script, $argument, $version) {495 if (sizeof($version) != 1)496 {497 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));498 }499 $script->setVersion(current($version));500 },501 array('-v', '--version'),502 '<string>',503 $this->locale->_('Version <string> will be used as version name')504 )505 ->addArgumentHandler(506 function($script, $argument, $unitTestRunnerScript) {507 if (sizeof($unitTestRunnerScript) != 1)508 {509 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));510 }511 $script->setUnitTestRunnerScript(current($unitTestRunnerScript));512 },513 array('-utrs', '--unit-test-runner-script')514 )515 ->addArgumentHandler(516 function($script, $argument, $pharGeneratorScript) {517 if (sizeof($pharGeneratorScript) != 1)518 {519 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));520 }521 $script->setPharGeneratorScript(current($pharGeneratorScript));522 },523 array('-pgs', '--phar-generator-script')524 )525 ->addArgumentHandler(526 function($script, $argument, $reportTitle) {527 if (sizeof($reportTitle) != 1)528 {529 throw new exceptions\logic\invalidArgument(sprintf($script->getLocale()->_('Bad usage of %s, do php %s --help for more informations'), $argument, $script->getName()));530 }531 $script->setReportTitle(current($reportTitle));532 },533 array('-rt', '--report-title')534 )535 ;536 }537 final protected function lock()538 {539 $runFile = $this->getRunFile();540 $pid = trim(541 @$this->adapter->file_get_contents($runFile)542 );543 $pid_exists = is_numeric($pid);544 if ($pid_exists !== false && $this->adapter->function_exists('posix_kill'))545 {546 $pid_exists = $this->adapter->posix_kill($pid, 0);547 }548 if ($pid_exists !== false)549 {550 throw new exceptions\runtime($this->locale->_('A process has locked run file \'%s\'', $runFile));551 }552 $this->lockResource = @$this->adapter->fopen($runFile, 'w+');553 if ($this->lockResource === false)554 {555 throw new exceptions\runtime($this->locale->_('Unable to open run file \'%s\'', $runFile));556 }557 if ($this->adapter->flock($this->lockResource, \LOCK_EX | \LOCK_NB) === false)558 {559 throw new exceptions\runtime($this->locale->_('Unable to get exclusive lock on run file \'%s\'', $runFile));560 }561 $this->adapter->fwrite($this->lockResource, $this->adapter->getmypid());562 return true;563 }564 final protected function unlock()565 {566 if ($this->lockResource !== null)567 {568 $this->adapter->fclose($this->lockResource);569 @$this->adapter->unlink($this->getRunFile());570 }571 }572 protected function doRun()573 {574 if ($this->pharCreationEnabled === true && $this->lock())575 {576 try577 {578 $this->createPhar($this->version);579 }580 catch (\Exception $exception)581 {582 $this->unlock();583 throw $exception;...
getRunFile
Using AI Code Generation
1$builder = new Builder();2$builder->getRunFile();3$builder = new Builder();4$builder->getRunFile();5$builder = new Builder();6$builder->getRunFile();7$builder = new Builder();8$builder->getRunFile();9$builder = new Builder();10$builder->getRunFile();11$builder = new Builder();12$builder->getRunFile();13$builder = new Builder();14$builder->getRunFile();15$builder = new Builder();16$builder->getRunFile();17$builder = new Builder();18$builder->getRunFile();19$builder = new Builder();20$builder->getRunFile();21$builder = new Builder();22$builder->getRunFile();23$builder = new Builder();24$builder->getRunFile();25$builder = new Builder();26$builder->getRunFile();27$builder = new Builder();28$builder->getRunFile();29$builder = new Builder();30$builder->getRunFile();31$builder = new Builder();32$builder->getRunFile();
getRunFile
Using AI Code Generation
1require_once 'builder.php';2$builder = new Builder();3$builder->getRunFile();4require_once 'builder.php';5$builder = new Builder();6$builder->getRunFile();7require_once 'builder.php';8$builder = new Builder();9$builder->getRunFile();10require_once 'builder.php';11$builder = new Builder();12$builder->getRunFile();13require_once 'builder.php';14$builder = new Builder();15$builder->getRunFile();16require_once 'builder.php';17$builder = new Builder();18$builder->getRunFile();19require_once 'builder.php';20$builder = new Builder();21$builder->getRunFile();22require_once 'builder.php';23$builder = new Builder();24$builder->getRunFile();25require_once 'builder.php';26$builder = new Builder();27$builder->getRunFile();28require_once 'builder.php';29$builder = new Builder();30$builder->getRunFile();31require_once 'builder.php';32$builder = new Builder();33$builder->getRunFile();34require_once 'builder.php';35$builder = new Builder();36$builder->getRunFile();37require_once 'builder.php';38$builder = new Builder();39$builder->getRunFile();
getRunFile
Using AI Code Generation
1$builder = new Builder();2$builder->getRunFile('1.php');3$builder = new Builder();4$builder->getRunFile('2.php');5$builder = new Builder();6$builder->getRunFile('3.php');7$builder = new Builder();8$builder->getRunFile('4.php');9$builder = new Builder();10$builder->getRunFile('5.php');11$builder = new Builder();12$builder->getRunFile('6.php');13$builder = new Builder();14$builder->getRunFile('7.php');15$builder = new Builder();16$builder->getRunFile('8.php');17$builder = new Builder();18$builder->getRunFile('9.php');19$builder = new Builder();20$builder->getRunFile('10.php');21$builder = new Builder();22$builder->getRunFile('11.php');23$builder = new Builder();24$builder->getRunFile('12.php');25$builder = new Builder();26$builder->getRunFile('13.php');27$builder = new Builder();28$builder->getRunFile('14.php');29$builder = new Builder();
getRunFile
Using AI Code Generation
1$builder = new Builder();2$builder->getRunFile();3$builder = new Builder();4$builder->getRunFile();5$builder = new Builder();6$builder->getRunFile();7$builder = new Builder();8$builder->getRunFile();9$builder = new Builder();10$builder->getRunFile();11$builder = new Builder();12$builder->getRunFile();13$builder = new Builder();14$builder->getRunFile();15$builder = new Builder();16$builder->getRunFile();17$builder = new Builder();18$builder->getRunFile();19$builder = new Builder();20$builder->getRunFile();21$builder = new Builder();22$builder->getRunFile();23$builder = new Builder();24$builder->getRunFile();
getRunFile
Using AI Code Generation
1require_once 'Builder.php';2$builder = new Builder();3$builder->getRunFile('1.php');4require_once 'Builder.php';5$builder = new Builder();6$builder->getRunFile('2.php');7require_once 'Builder.php';8$builder = new Builder();9$builder->getRunFile('3.php');10require_once 'Builder.php';11$builder = new Builder();12$builder->getRunFile('4.php');13require_once 'Builder.php';14$builder = new Builder();15$builder->getRunFile('5.php');16require_once 'Builder.php';17$builder = new Builder();18$builder->getRunFile('6.php');19require_once 'Builder.php';20$builder = new Builder();21$builder->getRunFile('7.php');22require_once 'Builder.php';23$builder = new Builder();24$builder->getRunFile('8.php');25require_once 'Builder.php';26$builder = new Builder();27$builder->getRunFile('9.php');28require_once 'Builder.php';29$builder = new Builder();30$builder->getRunFile('10.php');31require_once 'Builder.php';32$builder = new Builder();33$builder->getRunFile('11.php');34require_once 'Builder.php';35$builder = new Builder();36$builder->getRunFile('12.php');37require_once 'Builder.php';
getRunFile
Using AI Code Generation
1require_once('builder.php');2$builder = new Builder();3$builder->getRunFile('1.php');4require_once('builder.php');5$builder = new Builder();6$builder->getRunFile('2.php');7require_once('builder.php');8$builder = new Builder();9$builder->getRunFile('3.php');10require_once('builder.php');11$builder = new Builder();12$builder->getRunFile('4.php');13require_once('builder.php');14$builder = new Builder();15$builder->getRunFile('5.php');16require_once('builder.php');17$builder = new Builder();18$builder->getRunFile('6.php');19require_once('builder.php');20$builder = new Builder();21$builder->getRunFile('7.php');22require_once('builder.php');23$builder = new Builder();24$builder->getRunFile('8.php');25require_once('builder.php');26$builder = new Builder();27$builder->getRunFile('9.php');28require_once('builder.php');29$builder = new Builder();30$builder->getRunFile('10.php');31require_once('builder.php');32$builder = new Builder();33$builder->getRunFile('11.php');34require_once('builder.php');35$builder = new Builder();36$builder->getRunFile('12.php');37require_once('builder.php');
getRunFile
Using AI Code Generation
1require_once 'builder.php';2$builder = new Builder();3$builder->getRunFile('2.php');4require_once 'builder.php';5$builder = new Builder();6$builder->getRunFile('3.php');7require_once 'builder.php';8$builder = new Builder();9$builder->getRunFile('4.php');10require_once 'builder.php';11$builder = new Builder();12$builder->getRunFile('5.php');13require_once 'builder.php';14$builder = new Builder();15$builder->getRunFile('6.php');16require_once 'builder.php';17$builder = new Builder();18$builder->getRunFile('7.php');19require_once 'builder.php';20$builder = new Builder();21$builder->getRunFile('8.php');22require_once 'builder.php';23$builder = new Builder();24$builder->getRunFile('9.php');25require_once 'builder.php';26$builder = new Builder();27$builder->getRunFile('10.php');28require_once 'builder.php';29$builder = new Builder();30$builder->getRunFile('11.php');31require_once 'builder.php';32$builder = new Builder();33$builder->getRunFile('12.php');34require_once 'builder.php';
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with getRunFile on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!