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 // init
$process = new ProcessExecutor; $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'); touch('foo');
$process->execute('git add foo', $null); $exec('git add foo');
$process->execute('git commit -m init', $null); $exec('git commit -m init');
// non-composed tag & branch // non-composed tag & branch
$process->execute('git tag 0.5.0', $null); $exec('git tag 0.5.0');
$process->execute('git branch oldbranch', $null); $exec('git branch oldbranch');
// add composed tag & master branch // add composed tag & master branch
$composer = array('name' => 'a/b'); $composer = array('name' => 'a/b');
file_put_contents('composer.json', json_encode($composer)); file_put_contents('composer.json', json_encode($composer));
$process->execute('git add composer.json', $null); $exec('git add composer.json');
$process->execute('git commit -m addcomposer', $null); $exec('git commit -m addcomposer');
$process->execute('git tag 0.6.0', $null); $exec('git tag 0.6.0');
// add feature-a branch // 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'); file_put_contents('foo', 'bar feature');
$process->execute('git add foo', $null); $exec('git add foo');
$process->execute('git commit -m change-a', $null); $exec('git commit -m change-a');
// add version to composer.json // add version to composer.json
$process->execute('git checkout master', $null); $exec('git checkout master');
$composer['version'] = '1.0.0'; $composer['version'] = '1.0.0';
file_put_contents('composer.json', json_encode($composer)); file_put_contents('composer.json', json_encode($composer));
$process->execute('git add composer.json', $null); $exec('git add composer.json');
$process->execute('git commit -m addversion', $null); $exec('git commit -m addversion');
// create tag with wrong version in it // 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 // 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 // add feature-b branch
$process->execute('git checkout -b feature-b', $null); $exec('git checkout -b feature-b');
file_put_contents('foo', 'baz feature'); file_put_contents('foo', 'baz feature');
$process->execute('git add foo', $null); $exec('git add foo');
$process->execute('git commit -m change-b', $null); $exec('git commit -m change-b');
// add 1.0 branch // add 1.0 branch
$process->execute('git checkout master', $null); $exec('git checkout master');
$process->execute('git branch 1.0', $null); $exec('git branch 1.0');
// add 1.0.x branch // add 1.0.x branch
$process->execute('git branch 1.1.x', $null); $exec('git branch 1.1.x');
// update master to 2.0 // update master to 2.0
$composer['version'] = '2.0.0'; $composer['version'] = '2.0.0';
file_put_contents('composer.json', json_encode($composer)); file_put_contents('composer.json', json_encode($composer));
$process->execute('git add composer.json', $null); $exec('git add composer.json');
$process->execute('git commit -m bump-version', $null); $exec('git commit -m bump-version');
chdir($oldCwd); chdir($oldCwd);
} }