From 04216cf96d7d2a7fa881120162c6dc206d3d48a1 Mon Sep 17 00:00:00 2001 From: Francesco Abeni Date: Thu, 29 Oct 2015 11:12:58 +0100 Subject: [PATCH] Add local configuration file for RoboFile.php --- .gitignore | 1 + RoboFile.dist.ini | 5 +++++ RoboFile.php | 39 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 RoboFile.dist.ini diff --git a/.gitignore b/.gitignore index 29f0600..c730c7f 100644 --- a/.gitignore +++ b/.gitignore @@ -45,6 +45,7 @@ vendor/* # Robo robo.phar +RoboFile.ini # Test related files tests/acceptance.suite.yml diff --git a/RoboFile.dist.ini b/RoboFile.dist.ini new file mode 100644 index 0000000..e75403c --- /dev/null +++ b/RoboFile.dist.ini @@ -0,0 +1,5 @@ + true, // default is false +); diff --git a/RoboFile.php b/RoboFile.php index 02dfb6a..c5a19e1 100644 --- a/RoboFile.php +++ b/RoboFile.php @@ -17,6 +17,8 @@ class RoboFile extends \Robo\Tasks private $extension = ''; + private $configuration = array(); + /** * Set the Execute extension for Windows Operating System * @@ -40,6 +42,8 @@ class RoboFile extends \Robo\Tasks */ public function runTests($seleniumPath = null, $suite = 'acceptance') { + $this->configuration = $this->getConfiguration(); + $this->setExecExtension(); $this->createTestingSite(); @@ -154,12 +158,16 @@ class RoboFile extends \Robo\Tasks // Kill selenium server // $this->_exec('curl http://localhost:4444/selenium-server/driver/?cmd=shutDownSeleniumServer'); } - /** * Creates a testing Joomla site for running the tests (use it before run:test) */ public function createTestingSite() { + if (!empty($this->configuration['skipClone'])) { + $this->say('Reusing Joomla CMS site already present at tests/joomla-cms3'); + return; + } + // Get Joomla Clean Testing sites if (is_dir('tests/joomla-cms3')) { @@ -170,6 +178,35 @@ class RoboFile extends \Robo\Tasks $this->say('Joomla CMS site created at tests/joomla-cms3'); } + /** + * Get (optional) configuration from an external file + * + * @return array + */ + public function getConfiguration() + { + $configurationFile = __DIR__ . '/RoboFile.ini'; + if (!file_exists($configurationFile)) { + $this->say("No local configuration file"); + return array(); + } + + try { + require_once $configurationFile; + if (!is_array($configuration)) { + $this->say('Local configuration file is empty or wrong (it must contain a $configuration array'); + return array(); + } + + return $configuration; + } + catch (Exception $ex) + { + $this->say('Exception reading local configuration file: ' . $ex->getMessage()); + return array(); + } + } + /** * Runs Selenium Standalone Server. *