Skip to content

Commit

Permalink
Improving validation.
Browse files Browse the repository at this point in the history
  • Loading branch information
grasmash committed Jun 12, 2017
1 parent 4ae3e15 commit 510a45d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
3 changes: 2 additions & 1 deletion src/Robo/Commands/Tests/BehatCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function initialize() {
* @interactConfigureBehat
* @validateMySqlAvailable
* @validateDrupalIsInstalled
* @validateHashSaltIsPresent
* @validateSettingsFilesPresent
* @validateBehatIsConfigured
* @validateInsideVm
* @launchWebServer
Expand Down Expand Up @@ -168,6 +168,7 @@ protected function launchSelenium() {
->get('executor')
->execute($this->getConfigValue('composer.bin') . "/selenium-server-standalone -port {$this->seleniumPort} -log {$this->seleniumLogFile} > /dev/null 2>&1")
->background(TRUE)
// @todo Print output when this command fails.
->printOutput(TRUE)
->dir($this->getConfigValue('repo.root'))
->run();
Expand Down
3 changes: 2 additions & 1 deletion src/Robo/Common/Executor.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Acquia\Blt\Robo\Common;

use Acquia\Blt\Robo\Config\ConfigAwareTrait;
use Acquia\Blt\Robo\Exceptions\BltException;
use GuzzleHttp\Client;
use Psr\Log\LoggerAwareInterface;
use Psr\Log\LoggerAwareTrait;
Expand Down Expand Up @@ -189,7 +190,7 @@ public function wait(callable $callable, array $args, $message = '') {
usleep($checkEvery * 1000);
}

throw new BltException("Timed out");
throw new BltException("Timed out.");
}

/**
Expand Down
16 changes: 9 additions & 7 deletions src/Robo/Hooks/ValidateHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ public function validateDrupalIsInstalled(CommandData $commandData) {
* @hook validate @validateSettingsFileIsValid
*/
public function validateSettingsFileIsValid(CommandData $commandData) {
if (!$this->getInspector()
->isDrupalSettingsFilePresent()
) {
if (!$this->getInspector()->isDrupalSettingsFilePresent()) {
throw new BltException("Could not find settings.php for this site.");
}

Expand Down Expand Up @@ -107,16 +105,20 @@ public function validateMySqlAvailable() {
throw new BltException("MySql is not available. Please run `blt doctor` to diagnose the issue.");
}
}

/**
* Validates that salt.txt exists.
* Validates that required settings files exist.
*
* @hook validate @validateHashSaltIsPresent
* @hook validate @validateSettingsFilesPresent
*/
public function validateHashSaltIsPresent() {
public function validateSettingsFilesPresent() {
if (!$this->getInspector()->isHashSaltPresent()) {
// @todo Prompt to fix.
throw new BltException("salt.txt is not present. Please run `blt setup:settings` to generate it.");
}
if (!$this->getInspector()->isDrupalLocalSettingsFilePresent()) {
throw new BltException("Could not find settings.php for this site.");
}
// @todo Look for local.drushrc.php.
}

/**
Expand Down
1 change: 1 addition & 0 deletions src/Robo/Inspector/Inspector.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public function isDrupalSettingsFilePresent() {
public function isHashSaltPresent() {
return file_exists($this->getConfigValue('repo.root') . '/salt.txt');
}

/**
* Determines if Drupal local.settings.php file exists.
*
Expand Down

0 comments on commit 510a45d

Please sign in to comment.