Ejemplo n.º 1
0
 public function getCommandProvider()
 {
     if (OS::isWindows()) {
         return [['""', []], ['""', ['']], ['foo', ['foo']], ['foo bar', ['foo', 'bar']], ['foo "bar bar"', ['foo', 'bar bar']], ['foo "bar\\"bar"', ['foo', 'bar"bar']], ['"foo bar.exe"', ['foo bar.exe']], ['foo.exe "test\\\\"', ['foo.exe', 'test\\']], ['child.exe argument1 "argument 2" "\\some\\path with\\spaces"', ['child.exe', 'argument1', 'argument 2', '\\some\\path with\\spaces']], ['child.exe argument1 "she said, \\"you had me at hello\\"" "\\some\\path with\\spaces"', ['child.exe', 'argument1', 'she said, "you had me at hello"', '\\some\\path with\\spaces']], ['child.exe argument1 "argument\\"2" argument3 argument4', ['child.exe', 'argument1', 'argument"2', 'argument3', 'argument4']], ['child.exe "\\some\\directory with\\spaces\\\\" argument2', ['child.exe', '\\some\\directory with\\spaces\\', 'argument2']]];
     }
     return [["''", []], ["''", ['']], ['foo', ['foo']], ['foo bar', ['foo', 'bar']], ["foo 'bar bar'", ['foo', 'bar bar']], ["'foo bar'", ['foo bar']], ["foo 'test\\'", ['foo', 'test\\']], ['foo -x bar', ['foo', '-x', 'bar']], ['foo --bar x', ['foo', '--bar', 'x']], ["foo '--' x", ['foo', '--', 'x']]];
 }
Ejemplo n.º 2
0
 public function testLocalize()
 {
     if (OS::isWindows()) {
         $this->assertSame('a\\b', Path::localize('a/b'));
         $this->assertSame('a\\b', Path::localize('a\\b'));
     } else {
         $this->assertSame('a/b', Path::localize('a\\b'));
         $this->assertSame('a/b', Path::localize('a/b'));
     }
 }
Ejemplo n.º 3
0
 /**
  * @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);
 }
Ejemplo n.º 4
0
 /**
  * @dataProvider hasBinaryProvider
  *
  * @param bool   $expected
  * @param string $binaryName
  */
 public function testHasBinary($expected, $binaryName)
 {
     $this->assertSame($expected, OS::hasBinary($binaryName));
 }