From 8d3b0ad0474f972fde9c1c574052efa0151d6f35 Mon Sep 17 00:00:00 2001 From: lamech Date: Mon, 29 Jul 2019 22:05:44 +0000 Subject: [PATCH] Fix DrumkitContext. --- behat.yml | 3 +++ features/bootstrap/Drumkit/DrumkitContext.php | 21 ++++++++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/behat.yml b/behat.yml index ab7450d..0e84fa0 100644 --- a/behat.yml +++ b/behat.yml @@ -1,4 +1,7 @@ default: + autoload: + - "%paths.base%/features/bootstrap" + - "%paths.base%/.mk/features/bootstrap" suites: default: contexts: diff --git a/features/bootstrap/Drumkit/DrumkitContext.php b/features/bootstrap/Drumkit/DrumkitContext.php index 62dc38b..6692c82 100644 --- a/features/bootstrap/Drumkit/DrumkitContext.php +++ b/features/bootstrap/Drumkit/DrumkitContext.php @@ -55,7 +55,10 @@ private function setOrigDir() { } protected function getOutput() { - return $this->process->getOutPut(); + if ($this->process->isSuccessful()) { + return $this->process->getOutput(); + } + return $this->process->getErrorOutput(); } /** @@ -66,15 +69,19 @@ private function exec($command) { $this->process->setTimeout(300); $this->process->run(); - if ($this->debug) { - print_r("--- DEBUG START ---\n"); - print_r($this->getOutput()); - print_r("\n--- DEBUG END -----"); - } + $this->printDebug(); + } + + private function printDebug() { + if (!$this->debug) return; + print_r("--- DEBUG START ---\n"); + print_r($this->getOutput()); + print_r("\n--- DEBUG END -----"); } private function succeed($command) { $this->exec($command); + if (!$this->process->isSuccessful()) { throw new ProcessFailedException($this->process); } @@ -87,7 +94,7 @@ private function fail($command) { $this->exec($command); if ($this->process->isSuccessful()) { - throw new \RuntimeException($this->process->getOutput()); + throw new \RuntimeException($this->getOutput()); } }