Skip to content

Commit

Permalink
adjust Quoting in Gulp Test for windows and use the symfony escapeArg…
Browse files Browse the repository at this point in the history
…ument for correct escaping on windows
  • Loading branch information
pscheit committed Mar 31, 2015
1 parent 28cf105 commit 49656ff
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/Common/ExecCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,6 @@ protected function executeCommand($command)
}
$this->stopTimer();

return new Result($this, $process->getExitCode(), $process->getOutput(), ['time' => $this->getExecutionTime()]);
return new Result($this, $process->getExitCode(), $process->getOutput(), ['time' => $this->getExecutionTime()]);
}
}
3 changes: 2 additions & 1 deletion src/Task/Gulp/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Robo\Task\BaseTask;
use Robo\Exception\TaskException;
use Symfony\Component\Process\ProcessUtils;

abstract class Base extends BaseTask
{
Expand Down Expand Up @@ -73,6 +74,6 @@ public function __construct($task, $pathToGulp = null)

public function getCommand()
{
return "{$this->command} " . escapeshellarg($this->task) . "{$this->arguments}";
return "{$this->command} " . ProcessUtils::escapeArgument($this->task) . "{$this->arguments}";
}
}
73 changes: 51 additions & 22 deletions tests/unit/GulpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,42 +16,71 @@ protected function _before()
'getOutput' => new \Symfony\Component\Console\Output\NullOutput()
]);
}

// tests
public function testGulpRun()
{
verify(
$this->taskGulpRun('default','gulp')->getCommand()
)->equals('gulp \'default\'');

verify(
$this->taskGulpRun('another','gulp')->getCommand()
)->equals('gulp \'another\'');
$isWindows = defined('PHP_WINDOWS_VERSION_MAJOR');

if ($isWindows) {
verify(
$this->taskGulpRun('default','gulp')->getCommand()
)->equals('gulp "default"');

verify(
$this->taskGulpRun('another','gulp')->getCommand()
)->equals('gulp "another"');

verify(
$this->taskGulpRun('anotherWith weired!("\') Chars','gulp')->getCommand()
)->equals('gulp "anotherWith weired!(\"\') Chars"');

verify(
$this->taskGulpRun('anotherWith wired!("\') Chars','gulp')->getCommand()
)->equals("gulp 'anotherWith wired!(\"'\\'') Chars'");
verify(
$this->taskGulpRun('default','gulp')->silent()->getCommand()
)->equals('gulp "default" --silent');

verify(
$this->taskGulpRun('default','gulp')->noColor()->getCommand()
)->equals('gulp "default" --no-color');

verify(
$this->taskGulpRun('default','gulp')->silent()->getCommand()
)->equals('gulp \'default\' --silent');
verify(
$this->taskGulpRun('default','gulp')->color()->getCommand()
)->equals('gulp "default" --color');

verify(
$this->taskGulpRun('default','gulp')->noColor()->getCommand()
)->equals('gulp \'default\' --no-color');
verify(
$this->taskGulpRun('default','gulp')->simple()->getCommand()
)->equals('gulp "default" --tasks-simple');

verify(
$this->taskGulpRun('default','gulp')->color()->getCommand()
)->equals('gulp \'default\' --color');
} else {

verify(
$this->taskGulpRun('default','gulp')->simple()->getCommand()
)->equals('gulp \'default\' --tasks-simple');
verify(
$this->taskGulpRun('default','gulp')->getCommand()
)->equals('gulp \'default\'');

verify(
$this->taskGulpRun('another','gulp')->getCommand()
)->equals('gulp \'another\'');

verify(
$this->taskGulpRun('anotherWith weired!("\') Chars','gulp')->getCommand()
)->equals("gulp 'anotherWith weired!(\"'\\'') Chars'");

verify(
$this->taskGulpRun('default','gulp')->silent()->getCommand()
)->equals('gulp \'default\' --silent');

verify(
$this->taskGulpRun('default','gulp')->noColor()->getCommand()
)->equals('gulp \'default\' --no-color');

verify(
$this->taskGulpRun('default','gulp')->color()->getCommand()
)->equals('gulp \'default\' --color');

verify(
$this->taskGulpRun('default','gulp')->simple()->getCommand()
)->equals('gulp \'default\' --tasks-simple');
}
}

}

0 comments on commit 49656ff

Please sign in to comment.