Skip to content

Commit

Permalink
Merge pull request #530 from consolidation/win-tests
Browse files Browse the repository at this point in the history
Update CommandArgumentsTest for Windows.
  • Loading branch information
greg-1-anderson committed Jan 25, 2017
2 parents 9a60921 + 819d6a6 commit ee6a3cc
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 14 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
[![License](https://poser.pugx.org/consolidation/robo/license.png)](https://www.versioneye.com/user/projects/57c4a6fe968d64004d97620a?child=57c4a6fe968d64004d97620a#tab-licenses)

[![Build Status](https://travis-ci.org/consolidation/Robo.svg?branch=master)](https://travis-ci.org/consolidation/Robo)
[![Windows CI](https://ci.appveyor.com/api/projects/status/0823hnh06pw8ir4d?svg=true)](https://ci.appveyor.com/project/greg-1-anderson/robo)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/consolidation/Robo/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/consolidation/Robo/?branch=master)
[![Dependency Status](https://www.versioneye.com/user/projects/57c4a6fe968d64004d97620a/badge.svg?style=flat-square)](https://www.versioneye.com/user/projects/57c4a6fe968d64004d97620a)

Expand Down
8 changes: 7 additions & 1 deletion tests/cli/PackExtractCept.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,14 @@
$I->seeFileFound('structu.re', 'some/deeply/nested');
$I->seeFileFound('existing_file', 'some/deeply');

$linuxSupportedTypes = ['zip', 'tar', 'tar.gz', 'tar.bz2', 'tgz'];

$windowsSupportedTypes = ['zip'];

$supportedTypes = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? $windowsSupportedTypes : $linuxSupportedTypes;

// Test a bunch of archive types that we support
foreach (['zip', 'tar', 'tar.gz', 'tar.bz2', 'tgz'] as $archiveType) {
foreach ($supportedTypes as $archiveType) {
// First, take everything from the folder 'some/deeply' and make
// an archive for it located in 'deep'
$I->taskPack("deeply.$archiveType")
Expand Down
14 changes: 13 additions & 1 deletion tests/unit/Common/CommandArgumentsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,47 +17,58 @@ class CommandArgumentsTest extends \Codeception\Test\Unit
public function casesArgs() {
return [
'no arguments' => [
' ',
' ',
[],
],
'empty string' => [
" ''",
' ""',
[''],
],
'space' => [
" ' '",
' " "',
[' '],
],
'no escape - a' => [
" a",
" a",
['a'],
],
'no escape - A' => [
" A",
" A",
['A'],
],
'no escape - 0' => [
" 0",
" 0",
['0'],
],
'no escape - --' => [
" --",
" --",
['--'],
],
'no escape - @_~.' => [
" @_~.",
" @_~.",
['@_~.'],
],
'$' => [
" 'a\$b'",
' "a$b"',
['a$b'],
],
'*' => [
" 'a*b'",
' "a*b"',
['a*b'],
],
'multi' => [
" '' a '\$PATH'",
' "" a "$PATH"',
['', 'a', '$PATH'],
],
];
Expand All @@ -71,8 +82,9 @@ public function casesArgs() {
* @param string $expected
* @param array $args
*/
public function testArgs($expected, $args)
public function testArgs($expectedLinux, $expectedWindows, $args)
{
$expected = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? $expectedWindows : $expectedLinux;
$commandArguments = new CommandArgumentsHost();
$commandArguments->args($args);
$this->guy->assertEquals($expected, $commandArguments->getArguments());
Expand Down
7 changes: 6 additions & 1 deletion tests/unit/Task/ApiGenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,12 @@ public function testPHPUnitCommand()
->tree('Y') // boolean as string
->debug('n');

$cmd = 'apigen --config ./apigen.neon --source src --extensions php --exclude test --exclude tmp --skip-doc-path a --skip-doc-path b --charset \'utf8,iso88591\' --internal no --php yes --tree yes --debug no';
$linuxCmd = 'apigen --config ./apigen.neon --source src --extensions php --exclude test --exclude tmp --skip-doc-path a --skip-doc-path b --charset \'utf8,iso88591\' --internal no --php yes --tree yes --debug no';

$winCmd = 'apigen --config ./apigen.neon --source src --extensions php --exclude test --exclude tmp --skip-doc-path a --skip-doc-path b --charset "utf8,iso88591" --internal no --php yes --tree yes --debug no';

$cmd = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? $winCmd : $linuxCmd;

verify($task->getCommand())->equals($cmd);

$task->run();
Expand Down
16 changes: 14 additions & 2 deletions tests/unit/Task/GitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ public function testGitStackRun()

public function testGitStackCommands()
{
$linuxCmd = "git clone http://github.com/consolidation-org/Robo && git pull && git add -A && git commit -m 'changed' && git push && git tag 0.6.0 && git push origin 0.6.0";

$winCmd = 'git clone http://github.com/consolidation-org/Robo && git pull && git add -A && git commit -m "changed" && git push && git tag 0.6.0 && git push origin 0.6.0';

$cmd = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? $winCmd : $linuxCmd;

verify(
(new \Robo\Task\Vcs\GitStack())
->cloneRepo('http://github.com/consolidation-org/Robo')
Expand All @@ -41,11 +47,17 @@ public function testGitStackCommands()
->tag('0.6.0')
->push('origin', '0.6.0')
->getCommand()
)->equals("git clone http://github.com/consolidation-org/Robo && git pull && git add -A && git commit -m 'changed' && git push && git tag 0.6.0 && git push origin 0.6.0");
)->equals($cmd);
}

public function testGitStackCommandsWithTagMessage()
{
$linuxCmd = "git clone http://github.com/consolidation-org/Robo && git pull && git add -A && git commit -m 'changed' && git push && git tag -m 'message' 0.6.0 && git push origin 0.6.0";

$winCmd = 'git clone http://github.com/consolidation-org/Robo && git pull && git add -A && git commit -m "changed" && git push && git tag -m \'message\' 0.6.0 && git push origin 0.6.0';

$cmd = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? $winCmd : $linuxCmd;

verify(
(new \Robo\Task\Vcs\GitStack())
->cloneRepo('http://github.com/consolidation-org/Robo')
Expand All @@ -56,6 +68,6 @@ public function testGitStackCommandsWithTagMessage()
->tag('0.6.0', 'message')
->push('origin', '0.6.0')
->getCommand()
)->equals("git clone http://github.com/consolidation-org/Robo && git pull && git add -A && git commit -m 'changed' && git push && git tag -m 'message' 0.6.0 && git push origin 0.6.0");
)->equals($cmd);
}
}
30 changes: 21 additions & 9 deletions tests/unit/Task/RsyncTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ class RsyncTest extends \Codeception\TestCase\Test
// tests
public function testRsync()
{
$linuxCmd = 'rsync --recursive --exclude .git --exclude .svn --exclude .hg --checksum --whole-file --verbose --progress --human-readable --stats src/ \'dev@localhost:/var/www/html/app/\'';

$winCmd = 'rsync --recursive --exclude .git --exclude .svn --exclude .hg --checksum --whole-file --verbose --progress --human-readable --stats src/ "dev@localhost:/var/www/html/app/"';

$cmd = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? $winCmd : $linuxCmd;

verify(
(new \Robo\Task\Remote\Rsync())
->fromPath('src/')
Expand All @@ -25,9 +31,13 @@ public function testRsync()
->humanReadable()
->stats()
->getCommand()
)->equals(
'rsync --recursive --exclude .git --exclude .svn --exclude .hg --checksum --whole-file --verbose --progress --human-readable --stats src/ \'dev@localhost:/var/www/html/app/\''
);
)->equals($cmd);

$linuxCmd = 'rsync \'src/foo bar/baz\' \'dev@localhost:/var/path/with/a space\'';

$winCmd = 'rsync "src/foo bar/baz" "dev@localhost:/var/path/with/a space"';

$cmd = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? $winCmd : $linuxCmd;

// From the folder 'foo bar' (with space) in 'src' directory
verify(
Expand All @@ -37,9 +47,13 @@ public function testRsync()
->toUser('dev')
->toPath('/var/path/with/a space')
->getCommand()
)->equals(
'rsync \'src/foo bar/baz\' \'dev@localhost:/var/path/with/a space\''
);
)->equals($cmd);

$linuxCmd = 'rsync src/foo src/bar \'dev@localhost:/var/path/with/a space\'';

$winCmd = 'rsync src/foo src/bar "dev@localhost:/var/path/with/a space"';

$cmd = (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') ? $winCmd : $linuxCmd;

// Copy two folders, 'src/foo' and 'src/bar'
verify(
Expand All @@ -49,8 +63,6 @@ public function testRsync()
->toUser('dev')
->toPath('/var/path/with/a space')
->getCommand()
)->equals(
'rsync src/foo src/bar \'dev@localhost:/var/path/with/a space\''
);
)->equals($cmd);
}
}

0 comments on commit ee6a3cc

Please sign in to comment.