Skip to content

Commit

Permalink
Add tests for --root and for --patchlevel.
Browse files Browse the repository at this point in the history
  • Loading branch information
maruel committed Oct 15, 2009
1 parent 9137a5c commit 1bf0dda
Show file tree
Hide file tree
Showing 2 changed files with 159 additions and 17 deletions.
4 changes: 2 additions & 2 deletions buildbot/steps/source.py
Expand Up @@ -176,7 +176,8 @@ def start(self):
revision = self.computeSourceRevision(s.changes)
# if patch is None, then do not patch the tree after checkout

# 'patch' is None or a tuple of (patchlevel, diff)
# 'patch' is None or a tuple of (patchlevel, diff, root)
# root is optional.
patch = s.patch
if patch:
self.addCompleteLog("patch", patch[1])
Expand Down Expand Up @@ -1157,4 +1158,3 @@ def startVC(self):
assert slavever, "slave is too old, does not know about monotone"
cmd = LoggedRemoteCommand("monotone", self.args)
self.startCommand(cmd)

172 changes: 157 additions & 15 deletions buildbot/test/test_vc.py
Expand Up @@ -90,6 +90,15 @@
}
"""

# Test buildbot try --root support.
subdir_diff = p0_diff.replace('subdir/subdir.c', 'subdir.c')

# Test --patchlevel support.
p2_diff = p0_diff.replace('subdir/subdir.c', 'foo/bar/subdir/subdir.c')

# Used in do_patch() test.
PATCHLEVEL0, SUBDIR_ROOT, PATCHLEVEL2 = range(3)

# this patch does not include the filename headers, so it is
# patchlevel-neutral
TRY_PATCH = '''
Expand Down Expand Up @@ -726,7 +735,7 @@ def _do_vctest_export_2(self, bs):
#self.checkGotRevisionIsLatest(bs)
# VC 'export' is not required to have a got_revision

def do_patch(self):
def do_patch(self, type):
vctype = self.vctype
args = self.helper.vcargs
m = self.master
Expand All @@ -737,12 +746,19 @@ def do_patch(self):
s += ", %s=%s" % (k, repr(v))
s += ")"
self.config = config_vc % s

if type == PATCHLEVEL0:
self.patch = (0, p0_diff)
elif type == SUBDIR_ROOT:
self.patch = (0, subdir_diff, 'subdir')
elif type == PATCHLEVEL2:
self.patch = (2, p2_diff)
else:
raise NotImplementedError
m.loadConfig(self.config % "clobber")
m.readConfig = True
m.startService()

ss = SourceStamp(revision=self.helper.trunk[-1], patch=(0, p0_diff))
ss = SourceStamp(revision=self.helper.trunk[-1], patch=self.patch)

d = self.connectSlave()
d.addCallback(lambda res: self.doBuild(ss=ss))
Expand Down Expand Up @@ -783,7 +799,7 @@ def _doPatch_2(self, bs):
return self._doPatch_3()

def _doPatch_3(self, res=None):
ss = SourceStamp(revision=self.helper.trunk[-2], patch=(0, p0_diff))
ss = SourceStamp(revision=self.helper.trunk[-2], patch=self.patch)
d = self.doBuild(ss=ss)
d.addCallback(self._doPatch_4)
return d
Expand All @@ -802,7 +818,7 @@ def _doPatch_4(self, bs):
# now check that we can patch a branch
ss = SourceStamp(branch=self.helper.branchname,
revision=self.helper.branch[-1],
patch=(0, p0_diff))
patch=self.patch)
d = self.doBuild(ss=ss)
d.addCallback(self._doPatch_5)
return d
Expand Down Expand Up @@ -1041,6 +1057,8 @@ def _do_getpatch_branch_3(self, res):


def dumpPatch(self, patch):
# FIXME: This function is never called.
raise NotImplementedError
# this exists to help me figure out the right 'patchlevel' value
# should be returned by tryclient.getSourceStamp
n = self.mktemp()
Expand Down Expand Up @@ -1212,7 +1230,15 @@ def testCheckout(self):
return d

def testPatch(self):
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
d = self.do_patch(PATCHLEVEL2)
return d

def testCheckoutBranch(self):
Expand Down Expand Up @@ -1419,7 +1445,21 @@ def testPatch(self):
self.helper.vcargs = { 'baseURL': self.helper.svnurl + "/",
'defaultBranch': "sample/trunk",
}
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
self.helper.vcargs = { 'baseURL': self.helper.svnurl + "/",
'defaultBranch': "sample/trunk",
}
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
self.helper.vcargs = { 'baseURL': self.helper.svnurl + "/",
'defaultBranch': "sample/trunk",
}
d = self.do_patch(PATCHLEVEL2)
return d

def testCheckoutBranch(self):
Expand Down Expand Up @@ -1608,7 +1648,21 @@ def testPatch(self):
self.helper.vcargs = { 'p4port': self.helper.p4port,
'p4base': '//depot/',
'defaultBranch': 'trunk' }
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
self.helper.vcargs = { 'p4port': self.helper.p4port,
'p4base': '//depot/',
'defaultBranch': 'trunk' }
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
self.helper.vcargs = { 'p4port': self.helper.p4port,
'p4base': '//depot/',
'defaultBranch': 'trunk' }
d = self.do_patch(PATCHLEVEL2)
return d

VCS.registerVC(P4.vc_name, P4Helper())
Expand Down Expand Up @@ -1725,7 +1779,19 @@ def testCheckout(self):
def testPatch(self):
self.helper.vcargs = { 'baseURL': self.helper.darcs_base + "/",
'defaultBranch': "trunk" }
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
self.helper.vcargs = { 'baseURL': self.helper.darcs_base + "/",
'defaultBranch': "trunk" }
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
self.helper.vcargs = { 'baseURL': self.helper.darcs_base + "/",
'defaultBranch': "trunk" }
d = self.do_patch(PATCHLEVEL2)
return d

def testCheckoutBranch(self):
Expand Down Expand Up @@ -2027,7 +2093,19 @@ def testCheckoutHTTP(self):
def testPatch(self):
self.helper.vcargs = {'url': self.helper.archrep,
'version': self.helper.defaultbranch }
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
self.helper.vcargs = {'url': self.helper.archrep,
'version': self.helper.defaultbranch }
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
self.helper.vcargs = {'url': self.helper.archrep,
'version': self.helper.defaultbranch }
d = self.do_patch(PATCHLEVEL2)
return d

def testCheckoutBranch(self):
Expand Down Expand Up @@ -2105,7 +2183,25 @@ def testPatch(self):
'archive': self.helper.archname,
'version': self.helper.defaultbranch,
}
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
self.helper.vcargs = {'url': self.helper.archrep,
# Baz adds the required 'archive' argument
'archive': self.helper.archname,
'version': self.helper.defaultbranch,
}
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
self.helper.vcargs = {'url': self.helper.archrep,
# Baz adds the required 'archive' argument
'archive': self.helper.archname,
'version': self.helper.defaultbranch,
}
d = self.do_patch(PATCHLEVEL2)
return d

def testCheckoutBranch(self):
Expand Down Expand Up @@ -2328,7 +2424,19 @@ def checkSharedRepo(res):
def testPatch(self):
self.helper.vcargs = { 'baseURL': self.helper.bzr_base + "/",
'defaultBranch': "trunk" }
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
self.helper.vcargs = { 'baseURL': self.helper.bzr_base + "/",
'defaultBranch': "trunk" }
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
self.helper.vcargs = { 'baseURL': self.helper.bzr_base + "/",
'defaultBranch': "trunk" }
d = self.do_patch(PATCHLEVEL2)
return d

def testCheckoutBranch(self):
Expand Down Expand Up @@ -2548,7 +2656,19 @@ def testCheckout(self):
def testPatch(self):
self.helper.vcargs = { 'baseURL': self.helper.hg_base + "/",
'defaultBranch': "trunk" }
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
self.helper.vcargs = { 'baseURL': self.helper.hg_base + "/",
'defaultBranch': "trunk" }
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
self.helper.vcargs = { 'baseURL': self.helper.hg_base + "/",
'defaultBranch': "trunk" }
d = self.do_patch(PATCHLEVEL2)
return d

def testCheckoutBranch(self):
Expand Down Expand Up @@ -2744,7 +2864,17 @@ def testCheckout(self):

def testPatch(self):
self.helper.vcargs = self.default_args()
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
self.helper.vcargs = self.default_args()
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
self.helper.vcargs = self.default_args()
d = self.do_patch(PATCHLEVEL2)
return d

def testCheckoutBranch(self):
Expand Down Expand Up @@ -2992,7 +3122,19 @@ def testCheckout(self):
def testPatch(self):
self.helper.vcargs = { 'repourl': self.helper.gitrepo,
'branch': "master" }
d = self.do_patch()
d = self.do_patch(PATCHLEVEL0)
return d

def testPatchSubDir(self):
self.helper.vcargs = { 'repourl': self.helper.gitrepo,
'branch': "master" }
d = self.do_patch(SUBDIR_ROOT)
return d

def testPatchP2(self):
self.helper.vcargs = { 'repourl': self.helper.gitrepo,
'branch': "master" }
d = self.do_patch(PATCHLEVEL2)
return d

def testCheckoutBranch(self):
Expand Down

0 comments on commit 1bf0dda

Please sign in to comment.