Skip to content

Commit

Permalink
Fixes #2524: Improve output of deprecation validator on failure. (#2536)
Browse files Browse the repository at this point in the history
* Fixes #2524: Improve output of deprecation validator on failure.

* Cache deprecation rules in Travis CI.

* Add verbosity.

* Remove tests:php:sniff:deprecated from default build.

* Set verbosity correctly.
  • Loading branch information
grasmash authored Feb 12, 2018
1 parent d8c8d87 commit dbf9319
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 11 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ cache:
- "$HOME/.console"
- "$HOME/.drush/cache"
- "$HOME/.nvm"
- ".rules"

addons:
ssh_known_hosts: []
Expand Down
1 change: 1 addition & 0 deletions scripts/travis/.travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cache:
- "$HOME/.npm"
- "$HOME/.nvm"
- "vendor"
- ".rules"
# Cache front end dependencies to dramatically improve build time.
# - "docroot/themes/custom/mytheme/node_modules"
# - "docroot/themes/custom/mytheme/bower_components"
Expand Down
9 changes: 7 additions & 2 deletions src/Robo/Commands/Blt/UpdateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Acquia\Blt\Robo\Exceptions\BltException;
use Acquia\Blt\Update\Updater;
use Robo\Contract\VerbosityThresholdInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Filesystem\Filesystem;

/**
Expand Down Expand Up @@ -101,10 +102,14 @@ protected function initializeBlt() {
*
* @aliases bu update
*/
public function update() {
public function update($options = [
'since' => InputOption::VALUE_REQUIRED,
]) {
$this->rsyncTemplate();
$this->mungeProjectYml();
if ($this->executeSchemaUpdates($this->currentSchemaVersion)) {

$starting_version = $options['since'] ?: $this->currentSchemaVersion;
if ($this->executeSchemaUpdates($starting_version)) {
$this->updateSchemaVersionFile();
}
$this->cleanup();
Expand Down
1 change: 0 additions & 1 deletion src/Robo/Commands/Validate/AllCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ public function all() {
'tests:phpcs:sniff:all',
'tests:yaml:lint:all',
'tests:twig:lint:all',
'tests:php:sniff:deprecated',
]);

return $status_code;
Expand Down
28 changes: 21 additions & 7 deletions src/Robo/Commands/Validate/DeprecatedCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,28 @@ class DeprecatedCommand extends BltTasks {
*/
public function detect() {
$this->say("Checking for deprecated code...");
$task = $this->taskExecStack()
->dir($this->getConfigValue('repo.root'));

/** @var \Acquia\Blt\Robo\Filesets\FilesetManager $fileset_manager */
$fileset_manager = $this->getContainer()->get('filesetManager');
$fileset_ids = $this->getConfigValue('validate.deprecated.filesets');
$filesets = $fileset_manager->getFilesets($fileset_ids);
$bin = $this->getConfigValue('composer.bin');
$command = "'$bin/deprecation-detector' check '%s'";
$this->executeCommandAgainstFilesets($filesets, $command);
$dirs = [
'blt/src',
'docroot/modules/custom',
'tests/phpunit',
'tests/behat',
];

foreach ($dirs as $dir) {
if (file_exists($dir)) {
$bin = $this->getConfigValue('composer.bin');
$command = "$bin/deprecation-detector check '$dir'";
if ($this->output()->isVerbose()) {
$command .= " --verbose";
}
$task->exec($command);
}
}
$task->run();
// We intentionally do not fail for deprecated code.
}

}
5 changes: 4 additions & 1 deletion template/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,7 @@ atlassian-ide-plugin.xml
npm-debug.log

# Drush 9 Checksums
drush/sites/.checksums
drush/sites/.checksums

# Deprecation detector rules
.rules
16 changes: 16 additions & 0 deletions tests/phpunit/BltProject/DeprecatedCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

namespace Acquia\Blt\Tests\Blt;

use Acquia\Blt\Tests\BltProjectTestBase;

/**
* Class DeprecatedCommandTest.
*/
class DeprecatedCommandTest extends BltProjectTestBase {

public function testValidateCommand() {
$this->blt("tests:php:sniff:deprecated");
}

}

0 comments on commit dbf9319

Please sign in to comment.