1
0
Fork 0

Show failures more clearly in test setup

pull/1590/head
Jordi Boggiano 2013-02-16 00:15:18 +01:00
parent 2e12993c9c
commit 940c2a079d
1 changed files with 31 additions and 24 deletions

View File

@ -47,58 +47,65 @@ class VcsRepositoryTest extends \PHPUnit_Framework_TestCase
// init
$process = new ProcessExecutor;
$process->execute('git init', $null);
$exec = function ($command) use ($process) {
$cwd = getcwd();
if ($process->execute($command, $output, $cwd) !== 0) {
throw new \RuntimeException('Failed to execute '.$command.': '.$process->getErrorOutput());
}
};
$exec('git init');
touch('foo');
$process->execute('git add foo', $null);
$process->execute('git commit -m init', $null);
$exec('git add foo');
$exec('git commit -m init');
// non-composed tag & branch
$process->execute('git tag 0.5.0', $null);
$process->execute('git branch oldbranch', $null);
$exec('git tag 0.5.0');
$exec('git branch oldbranch');
// add composed tag & master branch
$composer = array('name' => 'a/b');
file_put_contents('composer.json', json_encode($composer));
$process->execute('git add composer.json', $null);
$process->execute('git commit -m addcomposer', $null);
$process->execute('git tag 0.6.0', $null);
$exec('git add composer.json');
$exec('git commit -m addcomposer');
$exec('git tag 0.6.0');
// add feature-a branch
$process->execute('git checkout -b feature/a-1.0-B', $null);
$exec('git checkout -b feature/a-1.0-B');
file_put_contents('foo', 'bar feature');
$process->execute('git add foo', $null);
$process->execute('git commit -m change-a', $null);
$exec('git add foo');
$exec('git commit -m change-a');
// add version to composer.json
$process->execute('git checkout master', $null);
$exec('git checkout master');
$composer['version'] = '1.0.0';
file_put_contents('composer.json', json_encode($composer));
$process->execute('git add composer.json', $null);
$process->execute('git commit -m addversion', $null);
$exec('git add composer.json');
$exec('git commit -m addversion');
// create tag with wrong version in it
$process->execute('git tag 0.9.0', $null);
$exec('git tag 0.9.0');
// create tag with correct version in it
$process->execute('git tag 1.0.0', $null);
$exec('git tag 1.0.0');
// add feature-b branch
$process->execute('git checkout -b feature-b', $null);
$exec('git checkout -b feature-b');
file_put_contents('foo', 'baz feature');
$process->execute('git add foo', $null);
$process->execute('git commit -m change-b', $null);
$exec('git add foo');
$exec('git commit -m change-b');
// add 1.0 branch
$process->execute('git checkout master', $null);
$process->execute('git branch 1.0', $null);
$exec('git checkout master');
$exec('git branch 1.0');
// add 1.0.x branch
$process->execute('git branch 1.1.x', $null);
$exec('git branch 1.1.x');
// update master to 2.0
$composer['version'] = '2.0.0';
file_put_contents('composer.json', json_encode($composer));
$process->execute('git add composer.json', $null);
$process->execute('git commit -m bump-version', $null);
$exec('git add composer.json');
$exec('git commit -m bump-version');
chdir($oldCwd);
}