/** * @covers nochso\Omni\VcsVersionInfo::extractTag * @covers nochso\Omni\VcsVersionInfo::readMercurial */ public function testMercurial() { if (!OS::hasBinary('hg') || getenv('TRAVIS')) { $this->markTestSkipped('hg (Mercurial) has to be available for this test.'); } $repoDir = Path::combine(self::$base, 'hg'); Folder::ensure($repoDir); // Set up a new repo with a single committed file Exec::create('hg')->run('init', $repoDir); // From now on prefix all 'hg' commands with repo and cwd path $hg = Exec::create('hg', '--repository', $repoDir, '--cwd', $repoDir); $fooPath = Path::combine($repoDir, 'foo.txt'); touch($fooPath); $hg->run('add', $fooPath); $hg->run('commit', '-m init', '-u', 'Unit tester'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertRegExp('/^[0-9a-f]+$/', $vcs->getVersion(), 'Version without a tag must be rev hash'); file_put_contents($fooPath, 'throw dirt at tree'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertRegExp('/^[0-9a-f]+-dirty$/', $vcs->getVersion(), 'Dirty version without a tag must end in -dirty'); $hg->run('tag', '-u', 'Unit tester', '1.0.0'); $hg->run('update', '1.0.0'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertSame('1.0.0-dirty', $vcs->getVersion(), 'Dirty version with a tag must end in -dirty'); $hg->run('update', '--clean', '1.0.0'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertSame('1.0.0', $vcs->getVersion(), 'Clean version at specific tag'); file_put_contents($fooPath, 'move on to next commit'); $hg->run('commit', '-m move-on', '-u', 'Unit tester'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertRegExp('/^1\\.0\\.0-1-m[0-9a-f]+$/', $vcs->getVersion(), 'Commit after latest tag'); file_put_contents($fooPath, 'throw more dirt at tree'); $vcs = new VcsVersionInfo('name', null, $repoDir); $this->assertRegExp('/^1\\.0\\.0-1-m[0-9a-f]+-dirty$/', $vcs->getVersion(), 'Commit after latest tag'); Folder::delete($repoDir); }
while ($n--) { $phpCsFixer->run($parameter); } chdir(__DIR__); }, 'php-cs-fixer Symfony', "```bash\n\$ " . $phpCsFixer->getCommand() . "\n```"); $phpFmt = Exec::create('fmt.phar', '--dry-run', '--psr'); $unit->addClosure(function ($n, $parameter) use($phpFmt) { chdir($parameter); while ($n--) { $phpFmt->run($parameter); } chdir(__DIR__); }, 'phpfmt PSR-2', "```bash\n\$ " . $phpFmt->getCommand() . "\n```"); foreach ($repos as $repoName => $repo) { $repoDir = Path::combine($tmpDir, 'repo', $repoName); if (!is_dir($repoDir)) { $clone = Exec::create('git')->run('clone', '--depth=1', '--single-branch', $repo, $repoDir); } $reset = Exec::create('git')->run('--git-dir=' . $repoDir . '/.git', '--work-tree=' . $repoDir, 'reset', '--hard', 'HEAD'); $phpCsCache = Path::combine($repoDir, '.php_cs.cache'); if (is_file($phpCsCache)) { unlink($phpCsCache); } $phpCsConfig = Path::combine($repoDir, '.php_cs'); if (is_file($phpCsConfig)) { unlink($phpCsConfig); } $unit->addParam(new Parameter($repoDir, $repoName, "[{$repo}]({$repo})")); } $report->unitList->add($unit); $report->run();
public function testFluentInvoke() { $runner = Exec::create('echo'); $this->assertSame(['test'], $runner('test')->getOutput()); }