def setUp(self): SubversionSetup.setUp(self) process = Process(quiet=True) process.system('svn mv -m"Rename" "file://%s/tags" "file://%s/tag"' % (self.packagedir, self.packagedir)) process.system('svn mv -m"Rename" "file://%s/branches" "file://%s/branch"' % (self.packagedir, self.packagedir))
def checkout(self, path='trunk', target=None): process = Process(quiet=True) if target is None: self.checkoutdir = join(self.tempdir, self.packagename) else: self.checkoutdir = join(self.tempdir, target, self.packagename) process.system('svn checkout file://%s/%s %s' % (self.repo, path, self.checkoutdir)) os.chdir(self.checkoutdir)
def clone(self): process = Process(quiet=True) process.system('git clone testpackage testclone') self.clonedir = join(self.tempdir, 'testclone') # Park the server on a branch because "Updating the currently # checked-out branch may cause confusion." self.dirstack.push('testpackage') process.system('git checkout -b parking') self.dirstack.pop()
def _fake_clone(self): # Fake a checkout, the real thing is too expensive process = Process(quiet=True) source = self._fake_source package = join(dirname(__file__), 'tests', source) archive = zipfile.ZipFile(package, 'r') archive.extractall() os.rename(source[:-4], 'testclone') self.dirstack.push('testclone') if self.scm.version_info[:2] >= (1, 7): url = process.popen('svn info')[1][2][5:] else: url = process.popen('svn info')[1][1][5:] process.system('svn switch --relocate %s file://%s/trunk' % (url, self.packagedir)) self.dirstack.pop() self.clonedir = join(self.tempdir, 'testclone')
def test_env(self): env = os.environ.copy() env['HELLO'] = 'Hello world' process = Process(env=env) rc = process.system('echo ${HELLO} > output') self.assertEqual(rc, 0) self.assertEqual(process.pipe('cat output'), 'Hello world')
def testGetGitifySubversion(self): """ Support git-svn-helpers/gitify style dual git/svn checkouts/clones. """ # Simulate a git-svn-helpers/gitify style dual svn/git checkout/clone svn_url = urlparse.urlunsplit(('file', '', self.packagedir, '', '')) git_svn_clonedir = self.clonedir + '.git-svn' process = Process(quiet=True) process.system( 'git svn clone -s {0} {1}'.format(svn_url, git_svn_clonedir)) os.rename( os.path.join(git_svn_clonedir, '.git'), os.path.join(self.clonedir, '.git')) scms = SCMFactory() self.assertEqual(scms.get_scm_from_url(svn_url).name, 'svn') self.assertEqual(scms.get_scm_from_sandbox(self.clonedir).name, 'svn')
def testAmbiguousSandbox(self): scms = SCMFactory() process = Process() self.dirstack.push(self.packagedir) process.system('hg init .') process.system('hg add README.txt setup.py testpackage/__init__.py') process.system('hg commit -m"Import"') self.dirstack.pop() self.assertRaises(SystemExit, scms.get_scm, None, self.packagedir)
def clone(self): process = Process(quiet=True) process.system('git clone testpackage testclone') self.clonedir = join(self.tempdir, 'testclone') # Park the server on a branch self.dirstack.push('testpackage') process.system('git checkout parking') self.dirstack.pop() # Make sure the clone is on master self.dirstack.push('testclone') process.system('git checkout master') self.dirstack.pop()
def remove(self, dir): process = Process(quiet=True) process.system('git rm setup.py')
def modifyprop(self, dir): process = Process(quiet=True) if self.scm.version_info[:2] >= (1, 8): process.system('svn propset format "text/x-python" setup.py') else: process.system('svn propset svn:format "text/x-python" setup.py')
def branch(self, dir, branchid): process = Process(quiet=True) process.system('git branch %s' % branchid) process.system('git checkout %s' % branchid)
def update(self, dir): process = Process(quiet=True) process.system('git checkout master')
def test_bad_cmd(self): process = Process() rc = process.system('$ "Hello world" 2> output') self.assertEqual(rc, 127)
def tag(self, dir, tagid): process = Process(quiet=True) process.system('hg tag %s' % tagid) process.system('hg update %s' % tagid)
def test_quiet(self): process = Process(quiet=True) rc = process.system('echo "Hello world"') self.assertEqual(rc, 0)
def tag(self, dir, tagid): process = Process(quiet=True) process.system('svn cp -m"Tag" file://%s/trunk %s' % (self.packagedir, tagid)) process.system('svn co %s testtag' % tagid) self.tagdir = join(self.tempdir, 'testtag')
def clone(self): process = Process(quiet=True) process.system('svn checkout file://%s/trunk testclone' % self.packagedir) self.clonedir = join(self.tempdir, 'testclone')
def clone(self): process = Process(quiet=True) process.system('hg clone testpackage testclone') self.clonedir = join(self.tempdir, 'testclone')
def tag(self, dir, tagid): process = Process(quiet=True) process.system('git tag %s' % tagid) process.system('git checkout %s' % tagid)
def test_simple(self): process = Process() rc = process.system('echo "Hello world" > output') self.assertEqual(rc, 0) self.assertEqual(process.pipe('cat output'), 'Hello world')
def modifyprop(self, dir): process = Process(quiet=True) process.system('svn propset svn:format "text/x-python" setup.py')
def branch(self, dir, branchid): process = Process(quiet=True) process.system('svn cp -m"Branch" file://%s/trunk %s' % (self.packagedir, branchid)) process.system('svn co %s testbranch' % branchid) self.branchdir = join(self.tempdir, 'testbranch')
def update(self, dir): process = Process(quiet=True) process.system('hg update')
def branch(self, dir, branchid): process = Process(quiet=True) process.system('hg branch %s' % branchid)