Skip to content

Commit

Permalink
Remove the redundant test. Add couple of more tests to mercurial comm…
Browse files Browse the repository at this point in the history
…and on slave.
  • Loading branch information
in3xes committed Jun 13, 2011
1 parent af14415 commit 6f52386
Showing 1 changed file with 69 additions and 8 deletions.
77 changes: 69 additions & 8 deletions slave/buildslave/test/unit/test_commands_hg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ def setUp(self):
def tearDown(self):
self.tearDownCommand()

def patch_sourcedirIsUpdateable(self, result):
self.cmd.sourcedirIsUpdateable = lambda : result

def patch_sourcedataMatches(self, result):
self.cmd.sourcedataMatches = lambda : result

def test_simple(self):
self.patch_getCommand('hg', 'path/to/hg')
self.clean_environ()
Expand Down Expand Up @@ -83,40 +89,94 @@ def test_simple(self):
d.addCallback(self.check_sourcedata, "http://bitbucket.org/nicolas17/pyboinc\n")
return d

def test_update(self):
def test_update_existing(self):
self.patch_getCommand('hg', 'path/to/hg')
self.clean_environ()
self.make_command(hg.Mercurial, dict(
workdir='workdir',
mode='update',
revision=None,
repourl='http://bitbucket.org/nicolas17/pyboinc',
))
),
initial_sourcedata = "http://bitbucket.org/nicolas17/pyboinc\n",
)
self.patch_sourcedirIsUpdateable(True)

exp_environ = dict(PWD='.', LC_MESSAGES='C')
expects = [
Expect([ 'clobber', 'workdir' ],
self.basedir)
Expect(['path/to/hg', 'pull', '--verbose', 'http://bitbucket.org/nicolas17/pyboinc'],
self.basedir_workdir,
sendRC=False, timeout=120, keepStdout=True, usePTY=False)
+ 0,
Expect(['path/to/hg', 'clone', '--verbose', '--noupdate',
'http://bitbucket.org/nicolas17/pyboinc', 'workdir'],
Expect(['path/to/hg', 'identify', '--num', '--branch'],
self.basedir_workdir,
sendRC=False, timeout=120, usePTY=False, keepStdout=True,
keepStderr=True)
+ { 'stdout' : '-1 default\n' }
+ 0,
Expect(['path/to/hg', 'paths', 'default'],
self.basedir_workdir,
sendRC=False, timeout=120, usePTY=False, keepStdout=True,
keepStderr=True)
+ { 'stdout' : 'http://bitbucket.org/nicolas17/pyboinc\n' }
+ 0,
Expect(['path/to/hg', 'update', '--clean', '--repository',
'workdir', '--rev', 'default'],
self.basedir,
sendRC=False, timeout=120, usePTY=False)
+ 0,
Expect(['path/to/hg', 'identify', '--id', '--debug'],
self.basedir_workdir,
sendRC=False, timeout=120, usePTY=False, environ=exp_environ,
keepStdout=True)
+ { 'stdout' : 'b7ddc0b638fa11cdac7c0345c40c6f76d8a7166d' }
+ 0,
]
self.patch_runprocess(*expects)
d = self.run_command()
d.addCallback(self.check_sourcedata, "http://bitbucket.org/nicolas17/pyboinc\n")
return d


def test_update_existing_change_branch(self):
self.patch_getCommand('hg', 'path/to/hg')
self.clean_environ()
self.make_command(hg.Mercurial, dict(
workdir='workdir',
mode='update',
revision=None,
branch='stable',
repourl='http://bitbucket.org/nicolas17/pyboinc',
clobberOnBranchChange=True,
),
initial_sourcedata = "http://bitbucket.org/nicolas17/pyboinc\n",
)
self.patch_sourcedirIsUpdateable(True)

exp_environ = dict(PWD='.', LC_MESSAGES='C')
expects = [
Expect(['path/to/hg', 'pull', '--verbose', 'http://bitbucket.org/nicolas17/pyboinc'],
self.basedir_workdir,
sendRC=False, timeout=120, keepStdout=True, usePTY=False)
+ 0,
Expect(['path/to/hg', 'identify', '--num', '--branch'],
self.basedir_workdir,
sendRC=False, timeout=120, usePTY=False, keepStdout=True,
keepStderr=True)
+ { 'stdout' : '-1 default\n' }
+ { 'stdout' : '1 default\n' }
+ 0,
Expect(['path/to/hg', 'paths', 'default'],
self.basedir_workdir,
sendRC=False, timeout=120, usePTY=False, keepStdout=True,
keepStderr=True)
+ { 'stdout' : 'http://bitbucket.org/nicolas17/pyboinc\n' }
+ 0,
Expect(['path/to/hg', 'purge', '--all'],
self.basedir_workdir,
keepStdout=True, keepStderr=True, usePTY=False)
+ 0,
Expect(['path/to/hg', 'update', '--clean', '--repository',
'workdir', '--rev', 'default'],
'workdir', '--rev', 'stable'],
self.basedir,
sendRC=False, timeout=120, usePTY=False)
+ 0,
Expand All @@ -126,6 +186,7 @@ def test_update(self):
keepStdout=True)
+ { 'stdout' : 'b7ddc0b638fa11cdac7c0345c40c6f76d8a7166d' }
+ 0,

]
self.patch_runprocess(*expects)
d = self.run_command()
Expand Down

0 comments on commit 6f52386

Please sign in to comment.