diff --git a/.travis.yml b/.travis.yml index 6faa5ee..9700a64 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,9 +5,13 @@ dist: trusty sudo: false +env: + - BEHAT_TAGS="~@slow" + - BEHAT_TAGS="@slow" + install: - make behat script: - . scripts/hacking.sh - - behat + - behat --tags=BEHAT_TAGS diff --git a/behat.yml b/behat.yml index 45c1ffb..3ad2af5 100644 --- a/behat.yml +++ b/behat.yml @@ -15,5 +15,5 @@ default: blackbox: ~ gherkin: filters: - tags: ~@wip + tags: "~@wip&&~@slow" diff --git a/features/bootstrap/FeatureContext.php b/features/bootstrap/FeatureContext.php index 190bbef..c5b9efa 100644 --- a/features/bootstrap/FeatureContext.php +++ b/features/bootstrap/FeatureContext.php @@ -27,6 +27,7 @@ class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext * context constructor through behat.yml. */ public function __construct() { + $this->setOrigDir(); } /** @@ -36,6 +37,16 @@ public function __destruct() { $this->rmdir($this->tempDir); } + private function getOrigDir() { + return $this->orig_dir; + } + + private function setOrigDir() { + if (!isset($this->orig_dir)) { + $this->orig_dir = getcwd(); + } + } + /** * Run a command in a sub-process, and set its output. */ @@ -76,7 +87,7 @@ private function fail($command) { * Create a temporary directory */ private function makeTempDir() { - $tempfile = tempnam(sys_get_temp_dir(),'behat_cli_'); + $tempfile = tempnam(sys_get_temp_dir(), 'behat_cli_'); if (file_exists($tempfile)) { unlink($tempfile); } @@ -90,8 +101,12 @@ private function makeTempDir() { private function rmdir($dir) { if (is_dir($dir)) { foreach(scandir($dir) as $file) { - if ('.' === $file || '..' === $file) continue; - if (is_dir("$dir/$file")) $this->rmdir("$dir/$file"); + if ('.' === $file || '..' === $file) { + continue; + } + if (is_dir("$dir/$file")) { + $this->rmdir("$dir/$file"); + } else unlink("$dir/$file"); } rmdir($dir); @@ -107,6 +122,16 @@ public function setDebugFlag() { $this->debug = TRUE; } + /** + * In case we switched to a temporary directory, switch back to the original + * directory before the next scenario. + * + * @AfterScenario + */ + public function returnToOrigDir() { + chdir($this->getOrigDir()); + } + /** * @When I run :command */ @@ -144,16 +169,10 @@ public function iShouldNotGet(PyStringNode $output) */ public function iAmInATemporaryDirectory() { - static $orig_dir; - if (!isset($orig_dir)) { - $orig_dir = getcwd(); - } - $this->orig_dir = $orig_dir; $this->makeTempDir(); chdir($this->tempDir); } - /** * Execute a script in our project, even if we've moved to a temporary directory. * @@ -161,9 +180,7 @@ public function iAmInATemporaryDirectory() */ public function iExecute($script) { - if (isset($this->orig_dir)) { - $script = $this->orig_dir . DIRECTORY_SEPARATOR . $script; - } + $script = $this->getOrigDir() . DIRECTORY_SEPARATOR . $script; $this->exec($script); } @@ -172,9 +189,7 @@ public function iExecute($script) */ public function executingShouldFail($script) { - if (isset($this->orig_dir)) { - $script = $this->orig_dir . DIRECTORY_SEPARATOR . $script; - } + $script = $this->getOrigDir() . DIRECTORY_SEPARATOR . $script; $this->fail($script); } diff --git a/features/cli_context.feature b/features/cli_context.feature index 1de9f22..b9b1433 100644 --- a/features/cli_context.feature +++ b/features/cli_context.feature @@ -11,7 +11,7 @@ Feature: CLI Context """ test.txt """ - Then I should not get: + And I should not get: """ Makefile """ diff --git a/features/install-drush.feature b/features/install-drush.feature index 4bc2e9c..db0d4bc 100644 --- a/features/install-drush.feature +++ b/features/install-drush.feature @@ -3,6 +3,7 @@ Feature: Install Drush locally As a Drupal developer I need to be able run Drush + @slow Scenario: Run 'make drush' Given I run "make clean-drush" When I run "make drush"