[16] | 1 | #!/usr/bin/python |
---|
| 2 | """Automated tests for MergeBot |
---|
[41] | 3 | |
---|
| 4 | Run from a Trac source tree with mergebot installed system-wide. (This needs |
---|
| 5 | to be reworked to be less cumbersome.) |
---|
[16] | 6 | """ |
---|
| 7 | |
---|
[64] | 8 | # TODO: The testcases need to be extended to cover the following: |
---|
| 9 | # - using a ticket #number as a version |
---|
| 10 | # - using a release version number as a version |
---|
| 11 | # - verify inter-ticket dependency checking |
---|
| 12 | # - verify failure cascades through inter-ticket dependencies |
---|
[67] | 13 | # - change the version of a ticket, rebranch, and merge |
---|
[64] | 14 | |
---|
[16] | 15 | import os |
---|
| 16 | import unittest |
---|
| 17 | import time |
---|
| 18 | import shutil |
---|
| 19 | |
---|
| 20 | from subprocess import call, Popen #, PIPE, STDOUT |
---|
| 21 | from twill.errors import TwillAssertionError |
---|
| 22 | |
---|
| 23 | |
---|
[40] | 24 | from trac.tests.functional import FunctionalTestSuite, FunctionalTester, FunctionalTwillTestCaseSetup, tc, b, logfile |
---|
| 25 | from trac.tests.functional.svntestenv import SvnFunctionalTestEnvironment |
---|
[54] | 26 | from trac.tests.contentgen import random_page, random_sentence #, random_word |
---|
[16] | 27 | |
---|
| 28 | |
---|
[17] | 29 | #class MergeBotTestEnvironment(FunctionalTestEnvironment): |
---|
| 30 | # """Slight change to FunctionalTestEnvironment to keep the PYTHONPATH from |
---|
| 31 | # our environment. |
---|
| 32 | # """ |
---|
| 33 | # def start(self): |
---|
| 34 | # """Starts the webserver""" |
---|
| 35 | # server = Popen(["python", "./trac/web/standalone.py", |
---|
| 36 | # "--port=%s" % self.port, "-s", |
---|
| 37 | # "--basic-auth=trac,%s," % self.htpasswd, |
---|
| 38 | # self.tracdir], |
---|
| 39 | # #env={'PYTHONPATH':'.'}, |
---|
| 40 | # stdout=logfile, stderr=logfile, |
---|
| 41 | # ) |
---|
| 42 | # self.pid = server.pid |
---|
| 43 | # time.sleep(1) # Give the server time to come up |
---|
| 44 | # |
---|
| 45 | # def _tracadmin(self, *args): |
---|
| 46 | # """Internal utility method for calling trac-admin""" |
---|
| 47 | # if call(["python", "./trac/admin/console.py", self.tracdir] + |
---|
| 48 | # list(args), |
---|
| 49 | # #env={'PYTHONPATH':'.'}, |
---|
| 50 | # stdout=logfile, stderr=logfile): |
---|
| 51 | # raise Exception('Failed running trac-admin with %r' % (args, )) |
---|
| 52 | # |
---|
| 53 | # |
---|
| 54 | #FunctionalTestEnvironment = MergeBotTestEnvironment |
---|
[16] | 55 | |
---|
| 56 | |
---|
| 57 | class MergeBotFunctionalTester(FunctionalTester): |
---|
| 58 | """Adds some MergeBot functionality to the functional tester.""" |
---|
| 59 | # FIXME: the tc.find( <various actions> ) checks are bogus: any ticket can |
---|
| 60 | # satisfy them, not just the one we're working on. |
---|
[44] | 61 | def __init__(self, trac_url, repo_url): |
---|
| 62 | FunctionalTester.__init__(self, trac_url) |
---|
| 63 | self.repo_url = repo_url |
---|
[16] | 64 | self.mergeboturl = self.url + '/mergebot' |
---|
| 65 | |
---|
| 66 | def wait_until_find(self, search, timeout=5): |
---|
| 67 | start = time.time() |
---|
| 68 | while time.time() - start < timeout: |
---|
| 69 | try: |
---|
[45] | 70 | #tc.reload() # This appears to re-POST |
---|
| 71 | tc.go(b.get_url()) |
---|
[16] | 72 | tc.find(search) |
---|
| 73 | return |
---|
| 74 | except TwillAssertionError: |
---|
| 75 | pass |
---|
| 76 | raise TwillAssertionError("Unable to find %r within %s seconds" % (search, timeout)) |
---|
| 77 | |
---|
| 78 | def wait_until_notfind(self, search, timeout=5): |
---|
| 79 | start = time.time() |
---|
| 80 | while time.time() - start < timeout: |
---|
| 81 | try: |
---|
[45] | 82 | #tc.reload() # This appears to re-POST |
---|
| 83 | tc.go(b.get_url()) |
---|
[16] | 84 | tc.notfind(search) |
---|
| 85 | return |
---|
| 86 | except TwillAssertionError: |
---|
| 87 | pass |
---|
| 88 | raise TwillAssertionError("Unable to notfind %r within %s seconds" % (search, timeout)) |
---|
| 89 | |
---|
| 90 | def go_to_mergebot(self): |
---|
| 91 | tc.go(self.mergeboturl) |
---|
| 92 | tc.url(self.mergeboturl) |
---|
| 93 | tc.notfind('No handler matched request to /mergebot') |
---|
| 94 | |
---|
[67] | 95 | def queue_branch(self, ticket_id): |
---|
[16] | 96 | self.go_to_mergebot() |
---|
| 97 | tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form |
---|
| 98 | tc.submit('Branch') |
---|
[67] | 99 | |
---|
| 100 | def branch(self, ticket_id, component, timeout=1): |
---|
| 101 | """timeout is in seconds.""" |
---|
| 102 | self.queue_branch(ticket_id) |
---|
[44] | 103 | self.wait_until_find('Nothing in the queue', timeout) |
---|
[16] | 104 | tc.find('Rebranch') |
---|
| 105 | tc.find('Merge') |
---|
| 106 | tc.find('CheckMerge') |
---|
| 107 | self.go_to_ticket(ticket_id) |
---|
| 108 | tc.find('Created branch from .* for .*') |
---|
| 109 | retval = call(['svn', 'ls', self.repo_url + '/' + component + '/branches/ticket-%s' % ticket_id], |
---|
| 110 | stdout=logfile, stderr=logfile) |
---|
| 111 | if retval: |
---|
| 112 | raise Exception('svn ls failed with exit code %s' % retval) |
---|
| 113 | |
---|
[67] | 114 | def queue_rebranch(self, ticket_id): |
---|
[16] | 115 | self.go_to_mergebot() |
---|
| 116 | tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form |
---|
| 117 | tc.submit('Rebranch') |
---|
[67] | 118 | |
---|
| 119 | def _rebranch(self, ticket_id, component, search, timeout=15): |
---|
| 120 | """timeout is in seconds.""" |
---|
| 121 | self.queue_rebranch(ticket_id) |
---|
[44] | 122 | self.wait_until_find('Nothing in the queue', timeout) |
---|
[16] | 123 | tc.find('Rebranch') |
---|
| 124 | tc.find('Merge') |
---|
| 125 | tc.find('CheckMerge') |
---|
| 126 | self.go_to_ticket(ticket_id) |
---|
[57] | 127 | tc.find(search) |
---|
[16] | 128 | retval = call(['svn', 'ls', self.repo_url + '/' + component + '/branches/ticket-%s' % ticket_id], |
---|
| 129 | stdout=logfile, stderr=logfile) |
---|
| 130 | if retval: |
---|
| 131 | raise Exception('svn ls failed with exit code %s' % retval) |
---|
| 132 | |
---|
[57] | 133 | def rebranch(self, ticket_id, component, timeout=15): |
---|
| 134 | self._rebranch(ticket_id, component, 'Rebranched from .* for .*', timeout) |
---|
| 135 | |
---|
| 136 | def rebranch_conflict(self, ticket_id, component, timeout=15): |
---|
| 137 | self._rebranch(ticket_id, component, 'There were conflicts on rebranching', timeout) |
---|
| 138 | |
---|
[67] | 139 | def queue_merge(self, ticket_id): |
---|
| 140 | self.go_to_mergebot() |
---|
| 141 | tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form |
---|
| 142 | tc.submit('Merge') |
---|
| 143 | |
---|
[16] | 144 | def merge(self, ticket_id, component, timeout=5): |
---|
[59] | 145 | self._merge(ticket_id, component, 'Merged .* to .* for', timeout) |
---|
| 146 | |
---|
| 147 | def merge_conflict(self, ticket_id, component, timeout=5): |
---|
| 148 | self._merge(ticket_id, component, 'Found [0-9]+ conflicts? in attempt to merge ', timeout) |
---|
| 149 | |
---|
| 150 | def _merge(self, ticket_id, component, search, timeout=5): |
---|
[16] | 151 | """timeout is in seconds.""" |
---|
[67] | 152 | self.queue_merge(ticket_id) |
---|
[44] | 153 | self.wait_until_find('Nothing in the queue', timeout) |
---|
[16] | 154 | tc.find('Branch') |
---|
| 155 | self.go_to_ticket(ticket_id) |
---|
[59] | 156 | tc.find(search) |
---|
[16] | 157 | # TODO: We may want to change this to remove the "dead" branch |
---|
| 158 | retval = call(['svn', 'ls', self.repo_url + '/' + component + '/branches/ticket-%s' % ticket_id], |
---|
| 159 | stdout=logfile, stderr=logfile) |
---|
| 160 | if retval: |
---|
| 161 | raise Exception('svn ls failed with exit code %s' % retval) |
---|
| 162 | |
---|
[67] | 163 | def queue_checkmerge(self, ticket_id): |
---|
[16] | 164 | self.go_to_mergebot() |
---|
| 165 | tc.formvalue('ops-%s' % ticket_id, 'ticket', ticket_id) # Essentially a noop to select the right form |
---|
| 166 | tc.submit('CheckMerge') |
---|
[67] | 167 | |
---|
| 168 | def checkmerge(self, ticket_id, component, timeout=5): |
---|
| 169 | """timeout is in seconds.""" |
---|
| 170 | self.queue_checkmerge(ticket_id) |
---|
[44] | 171 | self.wait_until_find('Nothing in the queue', timeout) |
---|
[16] | 172 | tc.find('Rebranch') |
---|
| 173 | tc.find('Merge') |
---|
| 174 | tc.find('CheckMerge') |
---|
| 175 | self.go_to_ticket(ticket_id) |
---|
| 176 | tc.find('while checking merge of') |
---|
| 177 | retval = call(['svn', 'ls', self.repo_url + '/' + component + '/branches/ticket-%s' % ticket_id], |
---|
| 178 | stdout=logfile, stderr=logfile) |
---|
| 179 | if retval: |
---|
| 180 | raise Exception('svn ls failed with exit code %s' % retval) |
---|
| 181 | |
---|
[67] | 182 | def wait_for_empty_queue(self, timeout=10): |
---|
| 183 | self.go_to_mergebot() |
---|
| 184 | self.wait_until_find('Nothing in the queue', timeout) |
---|
[16] | 185 | |
---|
[67] | 186 | |
---|
[16] | 187 | class MergeBotTestSuite(FunctionalTestSuite): |
---|
| 188 | def setUp(self): |
---|
| 189 | port = 8889 |
---|
| 190 | baseurl = "http://localhost:%s" % port |
---|
[40] | 191 | self._testenv = SvnFunctionalTestEnvironment("testenv%s" % port, port, baseurl) |
---|
[16] | 192 | |
---|
| 193 | # Configure mergebot |
---|
| 194 | env = self._testenv.get_trac_environment() |
---|
| 195 | env.config.set('components', 'mergebot.web_ui.mergebotmodule', 'enabled') |
---|
[40] | 196 | env.config.save() |
---|
[44] | 197 | os.mkdir(os.path.join("testenv%s" % port, 'trac', 'mergebot')) |
---|
[40] | 198 | self._testenv._tracadmin('upgrade') # sets up the bulk of the mergebot config |
---|
| 199 | env.config.parse_if_needed() |
---|
[16] | 200 | env.config.set('mergebot', 'repository_url', self._testenv.repo_url()) |
---|
| 201 | env.config.set('logging', 'log_type', 'file') |
---|
| 202 | env.config.save() |
---|
| 203 | env.config.parse_if_needed() |
---|
| 204 | |
---|
| 205 | self._testenv.start() |
---|
[44] | 206 | self._tester = MergeBotFunctionalTester(baseurl, self._testenv.repo_url()) |
---|
[47] | 207 | os.system('mergebotdaemon -f "%s" > %s/mergebotdaemon.log 2>&1 &' % (self._testenv.tracdir, self._testenv.tracdir)) |
---|
[40] | 208 | self.fixture = (self._testenv, self._tester) |
---|
[16] | 209 | |
---|
| 210 | # Setup some common component stuff for MergeBot's use: |
---|
| 211 | svnurl = self._testenv.repo_url() |
---|
| 212 | for component in ['stuff', 'flagship', 'submarine']: |
---|
| 213 | self._tester.create_component(component) |
---|
| 214 | if call(['svn', '-m', 'Create tree for "%s".' % component, 'mkdir', |
---|
| 215 | svnurl + '/' + component, |
---|
| 216 | svnurl + '/' + component + '/trunk', |
---|
| 217 | svnurl + '/' + component + '/tags', |
---|
| 218 | svnurl + '/' + component + '/branches'], |
---|
| 219 | stdout=logfile, stderr=logfile): |
---|
| 220 | raise Exception("svn mkdir failed") |
---|
| 221 | |
---|
| 222 | self._tester.create_version('trunk') |
---|
| 223 | |
---|
| 224 | |
---|
[51] | 225 | class FunctionalSvnTestCaseSetup(FunctionalTwillTestCaseSetup): |
---|
| 226 | def get_workdir(self): |
---|
| 227 | return os.path.join(self._testenv.dirname, self.__class__.__name__) |
---|
| 228 | |
---|
| 229 | def checkout(self, ticket_id=None): |
---|
| 230 | """checkout a working copy of the branch for the given ticket, or trunk if none given""" |
---|
| 231 | if ticket_id is None: |
---|
| 232 | svnurl = self._testenv.repo_url() + '/stuff/trunk' |
---|
| 233 | else: |
---|
| 234 | svnurl = self._testenv.repo_url() + '/stuff/branches/ticket-%s' % ticket_id |
---|
| 235 | retval = call(['svn', 'checkout', svnurl, self.get_workdir()], |
---|
| 236 | stdout=logfile, stderr=logfile) |
---|
| 237 | self.assertEqual(retval, 0, "svn checkout failed with error %s" % (retval)) |
---|
| 238 | |
---|
[64] | 239 | def cleanup(self): |
---|
| 240 | shutil.rmtree(self.get_workdir()) |
---|
| 241 | |
---|
[51] | 242 | def switch(self, ticket_id=None): |
---|
| 243 | if ticket_id is None: |
---|
| 244 | svnurl = self._testenv.repo_url() + '/stuff/trunk' |
---|
| 245 | else: |
---|
| 246 | svnurl = self._testenv.repo_url() + '/stuff/branches/ticket-%s' % ticket_id |
---|
| 247 | retval = call(['svn', 'switch', svnurl, self.get_workdir()], |
---|
| 248 | stdout=logfile, stderr=logfile) |
---|
| 249 | self.assertEqual(retval, 0, "svn checkout failed with error %s" % (retval)) |
---|
| 250 | |
---|
[67] | 251 | def add_new_file(self, filename=None, file_size=None): |
---|
[51] | 252 | workdir = self.get_workdir() |
---|
| 253 | if filename is None: |
---|
| 254 | newfile = os.path.join(workdir, self.__class__.__name__) |
---|
| 255 | else: |
---|
| 256 | newfile = os.path.join(workdir, filename) |
---|
[67] | 257 | if file_size is None: |
---|
| 258 | data = random_page() |
---|
| 259 | else: |
---|
| 260 | data = '' |
---|
| 261 | while len(data) < file_size: |
---|
| 262 | data += random_page() |
---|
| 263 | data = data[:file_size] |
---|
| 264 | open(newfile, 'w').write(data) |
---|
[51] | 265 | retval = call(['svn', 'add', newfile], |
---|
| 266 | cwd=workdir, |
---|
| 267 | stdout=logfile, stderr=logfile) |
---|
| 268 | self.assertEqual(retval, 0, "svn add failed with error %s" % (retval)) |
---|
| 269 | |
---|
| 270 | def commit(self, message, files=None): |
---|
| 271 | if files is None: |
---|
| 272 | files = ['.'] |
---|
[54] | 273 | commit_message = self.__class__.__name__ + ": " + message |
---|
| 274 | retval = call(['svn', 'commit', '-m', commit_message] + list(files), |
---|
[51] | 275 | cwd=self.get_workdir(), |
---|
| 276 | stdout=logfile, stderr=logfile) |
---|
| 277 | self.assertEqual(retval, 0, "svn commit failed with error %s" % (retval)) |
---|
| 278 | |
---|
[57] | 279 | def mv(self, oldname, newname): |
---|
| 280 | retval = call(['svn', 'mv', oldname, newname], |
---|
| 281 | cwd=self.get_workdir(), |
---|
| 282 | stdout=logfile, stderr=logfile) |
---|
| 283 | self.assertEqual(retval, 0, "svn mv failed with error %s" % (retval)) |
---|
[51] | 284 | |
---|
[62] | 285 | def propset(self, propname, propvalue, filename): |
---|
| 286 | retval = call(['svn', 'propset', propname, propvalue, filename], |
---|
| 287 | cwd=self.get_workdir(), |
---|
| 288 | stdout=logfile, stderr=logfile) |
---|
| 289 | self.assertEqual(retval, 0, "svn prposet failed with error %s" % (retval)) |
---|
| 290 | |
---|
[63] | 291 | def propdel(self, propname, filename): |
---|
| 292 | retval = call(['svn', 'propdel', propname, filename], |
---|
| 293 | cwd=self.get_workdir(), |
---|
| 294 | stdout=logfile, stderr=logfile) |
---|
| 295 | self.assertEqual(retval, 0, "svn prposet failed with error %s" % (retval)) |
---|
[57] | 296 | |
---|
[68] | 297 | def rm(self, filename): |
---|
| 298 | retval = call(['svn', 'rm', filename], |
---|
| 299 | cwd=self.get_workdir(), |
---|
| 300 | stdout=logfile, stderr=logfile) |
---|
| 301 | self.assertEqual(retval, 0, "svn rm failed with error %s" % (retval)) |
---|
[62] | 302 | |
---|
[68] | 303 | |
---|
[17] | 304 | class MergeBotTestEnabled(FunctionalTwillTestCaseSetup): |
---|
[16] | 305 | def runTest(self): |
---|
| 306 | self._tester.logout() |
---|
| 307 | tc.go(self._tester.url) |
---|
| 308 | self._tester.login('admin') |
---|
| 309 | tc.follow('MergeBot') |
---|
| 310 | mergeboturl = self._tester.url + '/mergebot' |
---|
| 311 | tc.url(mergeboturl) |
---|
| 312 | tc.notfind('No handler matched request to /mergebot') |
---|
| 313 | |
---|
| 314 | |
---|
[17] | 315 | class MergeBotTestNoVersion(FunctionalTwillTestCaseSetup): |
---|
[16] | 316 | """Verify that if a ticket does not have the version field set, it will not |
---|
| 317 | appear in the MergeBot list. |
---|
| 318 | """ |
---|
| 319 | def runTest(self): |
---|
| 320 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 321 | info={'component':'stuff', 'version':''}) |
---|
| 322 | tc.follow('MergeBot') |
---|
| 323 | tc.notfind(self.__class__.__name__) |
---|
| 324 | |
---|
| 325 | |
---|
[17] | 326 | class MergeBotTestBranch(FunctionalTwillTestCaseSetup): |
---|
[16] | 327 | def runTest(self): |
---|
| 328 | """Verify that the 'branch' button works""" |
---|
| 329 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 330 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 331 | self._tester.branch(ticket_id, 'stuff') |
---|
| 332 | |
---|
| 333 | |
---|
[17] | 334 | class MergeBotTestRebranch(FunctionalTwillTestCaseSetup): |
---|
[16] | 335 | def runTest(self): |
---|
| 336 | """Verify that the 'rebranch' button works""" |
---|
| 337 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 338 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 339 | self._tester.branch(ticket_id, 'stuff') |
---|
| 340 | self._tester.rebranch(ticket_id, 'stuff') |
---|
| 341 | |
---|
| 342 | |
---|
[17] | 343 | class MergeBotTestMerge(FunctionalTwillTestCaseSetup): |
---|
[16] | 344 | def runTest(self): |
---|
| 345 | """Verify that the 'merge' button works""" |
---|
| 346 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 347 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 348 | self._tester.branch(ticket_id, 'stuff') |
---|
| 349 | self._tester.merge(ticket_id, 'stuff') |
---|
| 350 | |
---|
| 351 | |
---|
[59] | 352 | class MergeBotTestMergeWithChange(FunctionalSvnTestCaseSetup): |
---|
| 353 | def runTest(self): |
---|
| 354 | """Verify that the 'merge' button works with changes on the branch""" |
---|
| 355 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 356 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 357 | self._tester.branch(ticket_id, 'stuff') |
---|
| 358 | |
---|
| 359 | # checkout a working copy & make a change |
---|
| 360 | self.checkout(ticket_id) |
---|
| 361 | # Create & add a new file |
---|
| 362 | self.add_new_file() |
---|
| 363 | self.commit('Add a new file') |
---|
| 364 | |
---|
| 365 | self._tester.merge(ticket_id, 'stuff') |
---|
| 366 | |
---|
[64] | 367 | self.cleanup() |
---|
[59] | 368 | |
---|
[67] | 369 | |
---|
[59] | 370 | class MergeBotTestMergeWithChangeAndTrunkChange(FunctionalSvnTestCaseSetup): |
---|
| 371 | def runTest(self): |
---|
| 372 | """Verify that the 'merge' button works with changes on the branch and trunk""" |
---|
| 373 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 374 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 375 | self._tester.branch(ticket_id, 'stuff') |
---|
| 376 | |
---|
| 377 | # checkout a working copy & make a change |
---|
| 378 | self.checkout(ticket_id) |
---|
| 379 | # Create & add a new file |
---|
| 380 | basename = self.__class__.__name__ |
---|
| 381 | self.add_new_file(basename + '-ticket') |
---|
| 382 | self.commit('Add a new file on ticket') |
---|
| 383 | self.switch() |
---|
| 384 | self.add_new_file(basename + '-trunk') |
---|
| 385 | self.commit('Add a new file on trunk') |
---|
| 386 | |
---|
| 387 | self._tester.merge(ticket_id, 'stuff') |
---|
[65] | 388 | self.cleanup() |
---|
[59] | 389 | |
---|
| 390 | |
---|
| 391 | class MergeBotTestMergeWithConflict(FunctionalSvnTestCaseSetup): |
---|
| 392 | def runTest(self): |
---|
| 393 | """Verify that the 'merge' button detects conflicts between the branch and trunk""" |
---|
| 394 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 395 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 396 | basename = self.__class__.__name__ |
---|
| 397 | |
---|
| 398 | # create a file in which to have conflicts |
---|
| 399 | self.checkout() |
---|
| 400 | self.add_new_file(basename) |
---|
| 401 | self.commit('Add a new file on trunk') |
---|
| 402 | |
---|
| 403 | # create the branch |
---|
| 404 | self._tester.branch(ticket_id, 'stuff') |
---|
| 405 | |
---|
| 406 | # modify the file on trunk |
---|
| 407 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 408 | self.commit('Modify the file on trunk') |
---|
| 409 | |
---|
| 410 | # modify the file on the branch |
---|
| 411 | self.switch(ticket_id) |
---|
| 412 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 413 | self.commit('Modify the file on branch') |
---|
| 414 | |
---|
| 415 | # merge, make sure it shows a conflict |
---|
| 416 | self._tester.merge_conflict(ticket_id, 'stuff') |
---|
| 417 | |
---|
[64] | 418 | self.cleanup() |
---|
[59] | 419 | |
---|
[64] | 420 | |
---|
[62] | 421 | class MergeBotTestMergeWithPropertyConflict(FunctionalSvnTestCaseSetup): |
---|
| 422 | def runTest(self): |
---|
| 423 | """Verify that the 'merge' button detects property conflicts between the branch and trunk""" |
---|
| 424 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 425 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 426 | basename = self.__class__.__name__ |
---|
| 427 | |
---|
| 428 | self.checkout() |
---|
| 429 | self.propset('svn:ignore', basename, '.') |
---|
| 430 | self.commit('set property on trunk') |
---|
| 431 | |
---|
| 432 | # create the branch |
---|
| 433 | self._tester.branch(ticket_id, 'stuff') |
---|
| 434 | |
---|
| 435 | # modify the property on trunk |
---|
| 436 | self.propset('svn:ignore', basename + '\ntrunk', '.') |
---|
| 437 | self.commit('Modify the property on trunk') |
---|
| 438 | |
---|
| 439 | # modify the property on the branch |
---|
| 440 | self.switch(ticket_id) |
---|
| 441 | self.propset('svn:ignore', basename + '\nbranch', '.') |
---|
| 442 | self.commit('Modify the property on branch') |
---|
| 443 | |
---|
| 444 | # merge, make sure it shows a conflict |
---|
| 445 | self._tester.merge_conflict(ticket_id, 'stuff') |
---|
| 446 | |
---|
[64] | 447 | self.cleanup() |
---|
[62] | 448 | |
---|
[64] | 449 | |
---|
[63] | 450 | class MergeBotTestMergeWithPropertyBranchDeleteConflict(FunctionalSvnTestCaseSetup): |
---|
| 451 | def runTest(self): |
---|
| 452 | """Verify that the 'merge' button detects property deleted on branch and modified on trunk""" |
---|
| 453 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 454 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 455 | basename = self.__class__.__name__ |
---|
| 456 | |
---|
| 457 | self.checkout() |
---|
| 458 | self.propset('svn:ignore', basename, '.') |
---|
| 459 | self.commit('set property on trunk') |
---|
| 460 | |
---|
| 461 | # create the branch |
---|
| 462 | self._tester.branch(ticket_id, 'stuff') |
---|
| 463 | |
---|
| 464 | # modify the property on trunk |
---|
| 465 | self.propset('svn:ignore', basename + '\ntrunk', '.') |
---|
| 466 | self.commit('Modify the property on trunk') |
---|
| 467 | |
---|
| 468 | # delete the property on the branch |
---|
| 469 | self.switch(ticket_id) |
---|
| 470 | self.propdel('svn:ignore', '.') |
---|
| 471 | self.commit('Delete the property on branch') |
---|
| 472 | |
---|
| 473 | # merge, make sure it shows a conflict |
---|
| 474 | self._tester.merge_conflict(ticket_id, 'stuff') |
---|
| 475 | |
---|
[64] | 476 | self.cleanup() |
---|
[63] | 477 | |
---|
[64] | 478 | |
---|
[63] | 479 | class MergeBotTestMergeWithPropertyTrunkDeleteConflict(FunctionalSvnTestCaseSetup): |
---|
| 480 | def runTest(self): |
---|
| 481 | """Verify that the 'merge' button detects property deleted on trunk and modified on branch""" |
---|
| 482 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 483 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 484 | basename = self.__class__.__name__ |
---|
| 485 | |
---|
| 486 | self.checkout() |
---|
| 487 | self.propset('svn:ignore', basename, '.') |
---|
| 488 | self.commit('set property on trunk') |
---|
| 489 | |
---|
| 490 | # create the branch |
---|
| 491 | self._tester.branch(ticket_id, 'stuff') |
---|
| 492 | |
---|
| 493 | # delete the property on trunk |
---|
| 494 | self.propdel('svn:ignore', '.') |
---|
| 495 | self.commit('Delete the property on trunk') |
---|
| 496 | |
---|
| 497 | # delete the property on the branch |
---|
| 498 | self.switch(ticket_id) |
---|
| 499 | self.propset('svn:ignore', basename + '\nbranch', '.') |
---|
| 500 | self.commit('Modify the property on branch') |
---|
| 501 | |
---|
| 502 | # merge, make sure it shows a conflict |
---|
| 503 | self._tester.merge_conflict(ticket_id, 'stuff') |
---|
| 504 | |
---|
[64] | 505 | self.cleanup() |
---|
[63] | 506 | |
---|
[64] | 507 | |
---|
[59] | 508 | class MergeBotTestMergeWithBranchRenameConflict(FunctionalSvnTestCaseSetup): |
---|
| 509 | def runTest(self): |
---|
| 510 | """Verify that the 'merge' button detects a conflict when a file renamed on the branch was modified on trunk""" |
---|
| 511 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 512 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 513 | basename = self.__class__.__name__ |
---|
| 514 | |
---|
| 515 | # create a file in which to have conflicts |
---|
| 516 | self.checkout() |
---|
| 517 | self.add_new_file(basename) |
---|
| 518 | self.commit('Add a new file on trunk') |
---|
| 519 | |
---|
| 520 | # create the branch |
---|
| 521 | self._tester.branch(ticket_id, 'stuff') |
---|
| 522 | |
---|
| 523 | # modify the file on trunk |
---|
| 524 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 525 | self.commit('Modify the file on trunk') |
---|
| 526 | |
---|
| 527 | # rename the file on the branch |
---|
| 528 | self.switch(ticket_id) |
---|
| 529 | self.mv(basename, basename + '-renamed') |
---|
| 530 | self.commit('Rename the file on the branch') |
---|
| 531 | |
---|
| 532 | self._tester.merge_conflict(ticket_id, 'stuff') |
---|
| 533 | |
---|
[64] | 534 | self.cleanup() |
---|
[59] | 535 | |
---|
[64] | 536 | |
---|
[59] | 537 | class MergeBotTestMergeWithTrunkRenameConflict(FunctionalSvnTestCaseSetup): |
---|
| 538 | def runTest(self): |
---|
| 539 | """Verify that the 'merge' button detects conflicts when a file renamed on trunk was modified on the branch""" |
---|
| 540 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 541 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 542 | basename = self.__class__.__name__ |
---|
| 543 | |
---|
| 544 | # create a file in which to have conflicts |
---|
| 545 | self.checkout() |
---|
| 546 | self.add_new_file(basename) |
---|
| 547 | self.commit('Add a new file on trunk') |
---|
| 548 | |
---|
| 549 | # create the branch |
---|
| 550 | self._tester.branch(ticket_id, 'stuff') |
---|
| 551 | |
---|
| 552 | # rename the file on trunk |
---|
| 553 | self.mv(basename, basename + '-renamed') |
---|
| 554 | self.commit('Rename the file on trunk') |
---|
| 555 | |
---|
| 556 | # rename the file on the branch |
---|
| 557 | self.switch(ticket_id) |
---|
| 558 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 559 | self.commit('Modify the file on the branch') |
---|
| 560 | |
---|
| 561 | # make sure it finds the conflict |
---|
| 562 | self._tester.merge_conflict(ticket_id, 'stuff') |
---|
| 563 | |
---|
[64] | 564 | self.cleanup() |
---|
[59] | 565 | |
---|
[64] | 566 | |
---|
[17] | 567 | class MergeBotTestCheckMerge(FunctionalTwillTestCaseSetup): |
---|
[16] | 568 | def runTest(self): |
---|
| 569 | """Verify that the 'checkmerge' button works""" |
---|
| 570 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 571 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 572 | self._tester.branch(ticket_id, 'stuff') |
---|
| 573 | self._tester.checkmerge(ticket_id, 'stuff') |
---|
| 574 | |
---|
| 575 | |
---|
[51] | 576 | class MergeBotTestRebranchWithChange(FunctionalSvnTestCaseSetup): |
---|
[46] | 577 | def runTest(self): |
---|
| 578 | """Verify that the 'rebranch' button works with changes on the branch""" |
---|
| 579 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 580 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 581 | self._tester.branch(ticket_id, 'stuff') |
---|
| 582 | |
---|
| 583 | # checkout a working copy & make a change |
---|
[51] | 584 | self.checkout(ticket_id) |
---|
[46] | 585 | # Create & add a new file |
---|
[51] | 586 | self.add_new_file() |
---|
| 587 | self.commit('Add a new file') |
---|
[46] | 588 | |
---|
| 589 | self._tester.rebranch(ticket_id, 'stuff') |
---|
[64] | 590 | self.cleanup() |
---|
[46] | 591 | |
---|
| 592 | |
---|
[51] | 593 | class MergeBotTestRebranchWithChangeAndTrunkChange(FunctionalSvnTestCaseSetup): |
---|
| 594 | def runTest(self): |
---|
[52] | 595 | """Verify that the 'rebranch' button works with changes on the branch and trunk""" |
---|
[51] | 596 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 597 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 598 | self._tester.branch(ticket_id, 'stuff') |
---|
| 599 | |
---|
| 600 | # checkout a working copy & make a change |
---|
| 601 | self.checkout(ticket_id) |
---|
| 602 | # Create & add a new file |
---|
| 603 | basename = self.__class__.__name__ |
---|
| 604 | self.add_new_file(basename + '-ticket') |
---|
| 605 | self.commit('Add a new file on ticket') |
---|
| 606 | self.switch() |
---|
| 607 | self.add_new_file(basename + '-trunk') |
---|
| 608 | self.commit('Add a new file on trunk') |
---|
| 609 | |
---|
| 610 | self._tester.rebranch(ticket_id, 'stuff') |
---|
[64] | 611 | self.cleanup() |
---|
[51] | 612 | |
---|
| 613 | |
---|
[54] | 614 | class MergeBotTestRebranchWithConflict(FunctionalSvnTestCaseSetup): |
---|
| 615 | def runTest(self): |
---|
[59] | 616 | """Verify that the 'rebranch' button detects conflicts between the branch and trunk""" |
---|
[54] | 617 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 618 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 619 | basename = self.__class__.__name__ |
---|
| 620 | |
---|
| 621 | # create a file in which to have conflicts |
---|
| 622 | self.checkout() |
---|
| 623 | self.add_new_file(basename) |
---|
| 624 | self.commit('Add a new file on trunk') |
---|
| 625 | |
---|
| 626 | # create the branch |
---|
| 627 | self._tester.branch(ticket_id, 'stuff') |
---|
| 628 | |
---|
| 629 | # modify the file on trunk |
---|
| 630 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 631 | self.commit('Modify the file on trunk') |
---|
| 632 | |
---|
| 633 | # modify the file on the branch |
---|
| 634 | self.switch(ticket_id) |
---|
| 635 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 636 | self.commit('Modify the file on branch') |
---|
| 637 | |
---|
[57] | 638 | # rebranch, make sure it shows a conflict |
---|
| 639 | self._tester.rebranch_conflict(ticket_id, 'stuff') |
---|
[54] | 640 | |
---|
[64] | 641 | self.cleanup() |
---|
[54] | 642 | |
---|
[64] | 643 | |
---|
[62] | 644 | class MergeBotTestRebranchWithPropertyConflict(FunctionalSvnTestCaseSetup): |
---|
| 645 | def runTest(self): |
---|
| 646 | """Verify that the 'rebranch' button detects property conflicts between the branch and trunk""" |
---|
| 647 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 648 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 649 | basename = self.__class__.__name__ |
---|
| 650 | |
---|
| 651 | self.checkout() |
---|
| 652 | self.propset('svn:ignore', basename, '.') |
---|
| 653 | self.commit('set property on trunk') |
---|
| 654 | |
---|
| 655 | # create the branch |
---|
| 656 | self._tester.branch(ticket_id, 'stuff') |
---|
| 657 | |
---|
| 658 | # modify the property on trunk |
---|
| 659 | self.propset('svn:ignore', basename + '\ntrunk', '.') |
---|
| 660 | self.commit('Modify the property on trunk') |
---|
| 661 | |
---|
| 662 | # modify the property on the branch |
---|
| 663 | self.switch(ticket_id) |
---|
| 664 | self.propset('svn:ignore', basename + '\nbranch', '.') |
---|
| 665 | self.commit('Modify the property on branch') |
---|
| 666 | |
---|
| 667 | # rebranch, make sure it shows a conflict |
---|
| 668 | self._tester.rebranch_conflict(ticket_id, 'stuff') |
---|
| 669 | |
---|
[64] | 670 | self.cleanup() |
---|
[62] | 671 | |
---|
[64] | 672 | |
---|
[63] | 673 | class MergeBotTestRebranchWithPropertyBranchDeleteConflict(FunctionalSvnTestCaseSetup): |
---|
| 674 | def runTest(self): |
---|
| 675 | """Verify that the 'rebranch' button detects property deleted on branch and modified on trunk""" |
---|
| 676 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 677 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 678 | basename = self.__class__.__name__ |
---|
| 679 | |
---|
| 680 | self.checkout() |
---|
| 681 | self.propset('svn:ignore', basename, '.') |
---|
| 682 | self.commit('set property on trunk') |
---|
| 683 | |
---|
| 684 | # create the branch |
---|
| 685 | self._tester.branch(ticket_id, 'stuff') |
---|
| 686 | |
---|
| 687 | # modify the property on trunk |
---|
| 688 | self.propset('svn:ignore', basename + '\ntrunk', '.') |
---|
| 689 | self.commit('Modify the property on trunk') |
---|
| 690 | |
---|
| 691 | # delete the property on the branch |
---|
| 692 | self.switch(ticket_id) |
---|
| 693 | self.propdel('svn:ignore', '.') |
---|
| 694 | self.commit('Delete the property on branch') |
---|
| 695 | |
---|
| 696 | # rebranch, make sure it shows a conflict |
---|
| 697 | self._tester.rebranch_conflict(ticket_id, 'stuff') |
---|
| 698 | |
---|
[64] | 699 | self.cleanup() |
---|
[63] | 700 | |
---|
[64] | 701 | |
---|
[63] | 702 | class MergeBotTestRebranchWithPropertyTrunkDeleteConflict(FunctionalSvnTestCaseSetup): |
---|
| 703 | def runTest(self): |
---|
| 704 | """Verify that the 'rebranch' button detects property deleted on trunk and modified on branch""" |
---|
| 705 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 706 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 707 | basename = self.__class__.__name__ |
---|
| 708 | |
---|
| 709 | self.checkout() |
---|
| 710 | self.propset('svn:ignore', basename, '.') |
---|
| 711 | self.commit('set property on trunk') |
---|
| 712 | |
---|
| 713 | # create the branch |
---|
| 714 | self._tester.branch(ticket_id, 'stuff') |
---|
| 715 | |
---|
| 716 | # delete the property on trunk |
---|
| 717 | self.propdel('svn:ignore', '.') |
---|
| 718 | self.commit('Delete the property on trunk') |
---|
| 719 | |
---|
| 720 | # delete the property on the branch |
---|
| 721 | self.switch(ticket_id) |
---|
| 722 | self.propset('svn:ignore', basename + '\nbranch', '.') |
---|
| 723 | self.commit('Modify the property on branch') |
---|
| 724 | |
---|
| 725 | # rebranch, make sure it shows a conflict |
---|
| 726 | self._tester.rebranch_conflict(ticket_id, 'stuff') |
---|
| 727 | |
---|
[64] | 728 | self.cleanup() |
---|
[63] | 729 | |
---|
[64] | 730 | |
---|
[57] | 731 | class MergeBotTestRebranchWithBranchRenameConflict(FunctionalSvnTestCaseSetup): |
---|
| 732 | def runTest(self): |
---|
[59] | 733 | """Verify that the 'rebranch' button detects a conflict when a file renamed on the branch was modified on trunk""" |
---|
[57] | 734 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 735 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 736 | basename = self.__class__.__name__ |
---|
| 737 | |
---|
| 738 | # create a file in which to have conflicts |
---|
| 739 | self.checkout() |
---|
| 740 | self.add_new_file(basename) |
---|
| 741 | self.commit('Add a new file on trunk') |
---|
| 742 | |
---|
| 743 | # create the branch |
---|
| 744 | self._tester.branch(ticket_id, 'stuff') |
---|
| 745 | |
---|
| 746 | # modify the file on trunk |
---|
| 747 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 748 | self.commit('Modify the file on trunk') |
---|
| 749 | |
---|
| 750 | # rename the file on the branch |
---|
| 751 | self.switch(ticket_id) |
---|
| 752 | self.mv(basename, basename + '-renamed') |
---|
[58] | 753 | self.commit('Rename the file on the branch') |
---|
[57] | 754 | |
---|
| 755 | self._tester.rebranch_conflict(ticket_id, 'stuff') |
---|
| 756 | |
---|
[64] | 757 | self.cleanup() |
---|
[57] | 758 | |
---|
[64] | 759 | |
---|
[58] | 760 | class MergeBotTestRebranchWithTrunkRenameConflict(FunctionalSvnTestCaseSetup): |
---|
| 761 | def runTest(self): |
---|
[59] | 762 | """Verify that the 'rebranch' button detects conflicts when a file renamed on trunk was modified on the branch""" |
---|
[58] | 763 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 764 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 765 | basename = self.__class__.__name__ |
---|
| 766 | |
---|
| 767 | # create a file in which to have conflicts |
---|
| 768 | self.checkout() |
---|
| 769 | self.add_new_file(basename) |
---|
| 770 | self.commit('Add a new file on trunk') |
---|
| 771 | |
---|
| 772 | # create the branch |
---|
| 773 | self._tester.branch(ticket_id, 'stuff') |
---|
| 774 | |
---|
| 775 | # rename the file on trunk |
---|
| 776 | self.mv(basename, basename + '-renamed') |
---|
| 777 | self.commit('Rename the file on trunk') |
---|
| 778 | |
---|
| 779 | # rename the file on the branch |
---|
| 780 | self.switch(ticket_id) |
---|
| 781 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 782 | self.commit('Modify the file on the branch') |
---|
| 783 | |
---|
| 784 | # make sure it finds the conflict |
---|
| 785 | self._tester.rebranch_conflict(ticket_id, 'stuff') |
---|
| 786 | |
---|
[64] | 787 | self.cleanup() |
---|
[58] | 788 | |
---|
[64] | 789 | |
---|
| 790 | class MergeBotTestSingleUseCase(FunctionalSvnTestCaseSetup): |
---|
[16] | 791 | def runTest(self): |
---|
| 792 | """Create a branch, make a change, checkmerge, and merge it.""" |
---|
| 793 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 794 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 795 | self._tester.branch(ticket_id, 'stuff') |
---|
| 796 | # checkout a working copy & make a change |
---|
[64] | 797 | self.checkout(ticket_id) |
---|
[16] | 798 | # Create & add a new file |
---|
[64] | 799 | self.add_new_file() |
---|
| 800 | self.commit('Add a new file') |
---|
[16] | 801 | self._tester.checkmerge(ticket_id, 'stuff') |
---|
| 802 | self._tester.merge(ticket_id, 'stuff') |
---|
[64] | 803 | self.cleanup() |
---|
[16] | 804 | |
---|
| 805 | |
---|
[64] | 806 | class MergeBotTestBranchReuse(FunctionalSvnTestCaseSetup): |
---|
| 807 | def runTest(self): |
---|
| 808 | """Merge a branch, branch it again, and merge it a second time.""" |
---|
| 809 | ticket_id = self._tester.create_ticket(summary=self.__class__.__name__, |
---|
| 810 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 811 | basename = self.__class__.__name__ |
---|
[16] | 812 | |
---|
[64] | 813 | self.checkout() |
---|
| 814 | self.add_new_file(basename) |
---|
| 815 | self.commit('Add a new file') |
---|
| 816 | |
---|
| 817 | self._tester.branch(ticket_id, 'stuff') |
---|
| 818 | self.switch(ticket_id) |
---|
| 819 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 820 | self.commit('Make a modification') |
---|
| 821 | self._tester.merge(ticket_id, 'stuff') |
---|
| 822 | |
---|
| 823 | self._tester.branch(ticket_id, 'stuff') |
---|
| 824 | self.switch(ticket_id) |
---|
| 825 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 826 | self.commit('Make a second modification') |
---|
| 827 | self._tester.merge(ticket_id, 'stuff') |
---|
| 828 | self.cleanup() |
---|
| 829 | |
---|
| 830 | |
---|
[67] | 831 | class MergeBotTestMergeDependency(FunctionalSvnTestCaseSetup): |
---|
| 832 | def runTest(self): |
---|
| 833 | """Merge two branches to trunk; make sure the second one shows as waiting""" |
---|
| 834 | # This test is fundamentally racy. The size of the files has been |
---|
| 835 | # chosen to slow down the test long enough to get a view of the |
---|
| 836 | # mergebot page with one of them waiting for the other to complete. |
---|
| 837 | ticket_one = self._tester.create_ticket(summary=self.__class__.__name__ + " one", |
---|
| 838 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 839 | ticket_two = self._tester.create_ticket(summary=self.__class__.__name__ + " two", |
---|
| 840 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 841 | basename = self.__class__.__name__ |
---|
| 842 | |
---|
| 843 | self._tester.branch(ticket_one, 'stuff') |
---|
| 844 | self._tester.branch(ticket_two, 'stuff') |
---|
| 845 | |
---|
| 846 | self.checkout(ticket_one) |
---|
| 847 | self.add_new_file(basename + '-one', 30*1024**2) |
---|
| 848 | self.commit('Add a new file') |
---|
| 849 | |
---|
| 850 | self.switch(ticket_two) |
---|
| 851 | self.add_new_file(basename + '-two', 30*1024**2) |
---|
| 852 | self.commit('Add a new file') |
---|
| 853 | |
---|
| 854 | self._tester.queue_merge(ticket_two) |
---|
| 855 | self._tester.queue_merge(ticket_one) |
---|
| 856 | |
---|
| 857 | #self._tester.go_to_mergebot() |
---|
| 858 | tc.find('Waiting') |
---|
[69] | 859 | self._tester.wait_for_empty_queue(180) # Has to be large for slow machines |
---|
[68] | 860 | |
---|
| 861 | self.switch() |
---|
| 862 | self.rm(basename + '-one') |
---|
| 863 | self.rm(basename + '-two') |
---|
| 864 | self.commit('Drop large files so later tests don\'t have to deal with them.') |
---|
[67] | 865 | self.cleanup() |
---|
| 866 | |
---|
| 867 | |
---|
[68] | 868 | class MergeBotTestMergeDependencyCascade(FunctionalSvnTestCaseSetup): |
---|
| 869 | def runTest(self): |
---|
| 870 | """Merge two branches to trunk; make sure the second is cancelled when |
---|
| 871 | the first hits merge conflicts. |
---|
| 872 | """ |
---|
| 873 | ticket_one = self._tester.create_ticket(summary=self.__class__.__name__ + " one", |
---|
| 874 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 875 | ticket_two = self._tester.create_ticket(summary=self.__class__.__name__ + " two", |
---|
| 876 | info={'component':'stuff', 'version':'trunk'}) |
---|
| 877 | basename = self.__class__.__name__ |
---|
| 878 | |
---|
| 879 | self.checkout() |
---|
| 880 | # create a file on trunk to work with |
---|
| 881 | # make it large enough to give us time to queue the second ticket |
---|
| 882 | # before this one completes its merge |
---|
| 883 | self.add_new_file(basename, 30*1024**2) |
---|
| 884 | self.commit('Add a new file') |
---|
| 885 | # branch the first ticket that we will have fail to merge due to |
---|
| 886 | # conflicts. |
---|
| 887 | self._tester.branch(ticket_one, 'stuff') |
---|
| 888 | # modify the file on trunk |
---|
| 889 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 890 | self.commit('Modify the file on trunk') |
---|
| 891 | # and modify the file on the branch |
---|
| 892 | self.switch(ticket_one) |
---|
| 893 | open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence()) |
---|
| 894 | self.commit('Modify the file on branch in conflicting manner') |
---|
| 895 | # create a branch for the second ticket with a non-conflicting change |
---|
| 896 | self._tester.branch(ticket_two, 'stuff') |
---|
| 897 | self.switch(ticket_two) |
---|
| 898 | self.add_new_file(basename + '-two') |
---|
| 899 | self.commit('Add a new file') |
---|
| 900 | |
---|
| 901 | # the stage is set. Now we request the merge that will conflict, |
---|
| 902 | # followed by the merge that won't, and wait for the merges to complete. |
---|
| 903 | self._tester.queue_merge(ticket_one) |
---|
| 904 | self._tester.queue_merge(ticket_two) |
---|
[69] | 905 | self._tester.wait_for_empty_queue(180) # Has to be large for slow machines |
---|
[68] | 906 | # Then we verify that one had conflicts, and one was cancelled. |
---|
| 907 | self._tester.go_to_ticket(ticket_one) |
---|
| 908 | tc.find('Found [0-9]+ conflicts? in attempt to merge ') |
---|
| 909 | self._tester.go_to_ticket(ticket_two) |
---|
| 910 | tc.notfind('Merged .* to .* for') |
---|
| 911 | # and clean up the mess |
---|
| 912 | self.cleanup() |
---|
| 913 | |
---|
| 914 | |
---|
[16] | 915 | def suite(): |
---|
| 916 | suite = MergeBotTestSuite() |
---|
| 917 | suite.addTest(MergeBotTestEnabled()) |
---|
| 918 | suite.addTest(MergeBotTestNoVersion()) |
---|
| 919 | suite.addTest(MergeBotTestBranch()) |
---|
[45] | 920 | suite.addTest(MergeBotTestRebranch()) |
---|
[16] | 921 | suite.addTest(MergeBotTestCheckMerge()) |
---|
[45] | 922 | suite.addTest(MergeBotTestMerge()) |
---|
[46] | 923 | suite.addTest(MergeBotTestRebranchWithChange()) |
---|
[51] | 924 | suite.addTest(MergeBotTestRebranchWithChangeAndTrunkChange()) |
---|
[54] | 925 | suite.addTest(MergeBotTestRebranchWithConflict()) |
---|
[62] | 926 | suite.addTest(MergeBotTestRebranchWithPropertyConflict()) |
---|
[57] | 927 | suite.addTest(MergeBotTestRebranchWithBranchRenameConflict()) |
---|
[58] | 928 | suite.addTest(MergeBotTestRebranchWithTrunkRenameConflict()) |
---|
[63] | 929 | suite.addTest(MergeBotTestRebranchWithPropertyBranchDeleteConflict()) |
---|
| 930 | suite.addTest(MergeBotTestRebranchWithPropertyTrunkDeleteConflict()) |
---|
[59] | 931 | suite.addTest(MergeBotTestMergeWithChange()) |
---|
| 932 | suite.addTest(MergeBotTestMergeWithChangeAndTrunkChange()) |
---|
| 933 | suite.addTest(MergeBotTestMergeWithConflict()) |
---|
[62] | 934 | suite.addTest(MergeBotTestMergeWithPropertyConflict()) |
---|
[59] | 935 | suite.addTest(MergeBotTestMergeWithBranchRenameConflict()) |
---|
| 936 | suite.addTest(MergeBotTestMergeWithTrunkRenameConflict()) |
---|
[63] | 937 | suite.addTest(MergeBotTestMergeWithPropertyBranchDeleteConflict()) |
---|
| 938 | suite.addTest(MergeBotTestMergeWithPropertyTrunkDeleteConflict()) |
---|
[16] | 939 | suite.addTest(MergeBotTestSingleUseCase()) |
---|
[64] | 940 | suite.addTest(MergeBotTestBranchReuse()) |
---|
[67] | 941 | suite.addTest(MergeBotTestMergeDependency()) |
---|
[68] | 942 | suite.addTest(MergeBotTestMergeDependencyCascade()) |
---|
[16] | 943 | return suite |
---|
| 944 | |
---|
| 945 | if __name__ == '__main__': |
---|
| 946 | unittest.main(defaultTest='suite') |
---|