Skip to content

Commit

Permalink
Merge branch 'monotone-integration' of github.com:levitte/buildbot
Browse files Browse the repository at this point in the history
  • Loading branch information
Amber Yust committed Apr 5, 2011
2 parents 969674d + b1c6932 commit 44015b3
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 32 deletions.
5 changes: 4 additions & 1 deletion slave/buildslave/commands/mtn.py
Expand Up @@ -22,6 +22,9 @@
from buildslave import runprocess
#from buildslave.util import remove_userpassword

class MonotoneError(Exception):
"""Error class for this module."""


class Monotone(SourceBaseCommand):
"""Monotone specific VC operation. In addition to the arguments
Expand Down Expand Up @@ -167,7 +170,7 @@ def afterCheckRepo(res, cdi):
self.command = c
return c.start()
elif cdi.stdout.find("(too new, cannot use)") > 0:
raise Exception, "The database is of a newer format than mtn can handle... Abort!"
raise MonotoneError, "The database is of a newer format than mtn can handle... Abort!"
else:
return defer.succeed(res)
d.addCallback(afterCheckRepo, c)
Expand Down
62 changes: 31 additions & 31 deletions slave/buildslave/test/unit/test_commands_mtn.py
Expand Up @@ -18,6 +18,7 @@

from twisted.trial import unittest
from twisted.internet import defer
from twisted.python import failure

from buildslave.test.fake.runprocess import Expect
from buildslave.test.util.sourcecommand import SourceCommandTestMixin
Expand Down Expand Up @@ -153,37 +154,36 @@ def test_db_needs_migrating(self):
d.addCallback(self.check_sourcedata, self.repourl+"?"+self.branch)
return d

# TODO: figure out how to catch a raised exception
# def test_db_too_new(self):
# "Test a basic invocation with mode=copy and no existing sourcedir"
# self.patch_getCommand('mtn', 'path/to/mtn')
# self.clean_environ()
# self.make_command(mtn.Monotone, dict(
# workdir='workdir',
# mode='copy',
# revision=None,
# repourl=self.repourl,
# branch=self.branch
# ),
# # no sourcedata -> will do fresh checkout
# initial_sourcedata = None,
# )
# exp_environ = dict(PWD='.', LC_MESSAGES='C')
# expects = [
# Expect([ 'path/to/mtn', 'db', 'info',
# '--db', os.path.join(self.basedir, 'db.mtn') ],
# self.basedir,
# keepStdout=True, sendRC=False, sendStderr=False,
# usePTY=False, environ=exp_environ)
# + { 'stdout' : 'blah blah (too new, cannot use)\n' },
# + 0,
# ]
#
# self.patch_runprocess(*expects)
#
# d = self.run_command()
# d.addCallback(self.check_sourcedata, self.repourl+"?"+self.branch)
# return d
def test_db_too_new(self):
"Test a basic invocation with mode=copy and no existing sourcedir"
self.patch_getCommand('mtn', 'path/to/mtn')
self.clean_environ()
self.make_command(mtn.Monotone, dict(
workdir='workdir',
mode='copy',
revision=None,
repourl=self.repourl,
branch=self.branch
),
# no sourcedata -> will do fresh checkout
initial_sourcedata = None,
)

exp_environ = dict(PWD='.', LC_MESSAGES='C')
expects = [
Expect([ 'path/to/mtn', 'db', 'info',
'--db', os.path.join(self.basedir, 'db.mtn') ],
self.basedir,
keepStdout=True, sendRC=False, sendStderr=False,
usePTY=False, environ=exp_environ)
+ { 'stdout' : 'blah blah (too new, cannot use)\n' }
+ 0
]

self.patch_runprocess(*expects)

d = self.run_command()
return self.assertFailure(d, mtn.MonotoneError)

def test_run_mode_copy_fresh_sourcedir(self):
"Test a basic invocation with mode=copy and no existing sourcedir"
Expand Down

0 comments on commit 44015b3

Please sign in to comment.