Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OPENEUROPA-696 Make sure the Task Runner provides current working directory as a replaceable token #56

Merged
merged 1 commit into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions config/runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
# -----------------------------------------------------------------------------
# Global Task Runner settings
# -----------------------------------------------------------------------------
#
# The "runner.working_dir" will contain the full path to current working directory.
# @see OpenEuropa\TaskRunner\TaskRunner::createConfiguration()
runner:
bin_dir: "./vendor/bin"
# working_dir: ~

# -----------------------------------------------------------------------------
# Drupal-related settings.
Expand Down
8 changes: 6 additions & 2 deletions src/TaskRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,15 @@ private function getCommandDiscovery()
*/
private function createConfiguration()
{
return Robo::createConfiguration([
$config = new Config();
$config->set('runner.working_dir', realpath($this->workingDir));
Robo::loadConfiguration([
__DIR__.'/../config/runner.yml',
'runner.yml.dist',
'runner.yml',
]);
], $config);

return $config;
}

/**
Expand Down
20 changes: 20 additions & 0 deletions tests/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use OpenEuropa\TaskRunner\Tests\AbstractTest;
use Symfony\Component\Console\Input\StringInput;
use Symfony\Component\Console\Output\BufferedOutput;
use Symfony\Component\Console\Output\NullOutput;
use Symfony\Component\Yaml\Yaml;

/**
Expand Down Expand Up @@ -158,6 +159,25 @@ public function testSettingsSetup(array $config, array $expected)
}
}

/**
* Test current working directory as a replaceable token.
*/
public function testWorkingDirectoryToken()
{
$configFile = $this->getSandboxFilepath('runner.yml');
$config = [
'working_dir' => '${runner.working_dir}',
];
file_put_contents($configFile, Yaml::dump($config));

$input = new StringInput("list --working-dir=".$this->getSandboxRoot());
$runner = new TaskRunner($input, new NullOutput());
$runner->run();

$this->assertContains('/tests/sandbox', $runner->getConfig()->get('runner.working_dir'));
$this->assertContains('/tests/sandbox', $runner->getConfig()->get('working_dir'));
}

/**
* @return array
*/
Expand Down