Changeset 59 for mergebot/trunk


Ignore:
Timestamp:
Feb 23, 2010 8:54:50 PM (15 years ago)
Author:
retracile
Message:

Mergebot: add testcases for merge operations

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mergebot/trunk/utils/test.py

    r58 r59  
    125125
    126126    def merge(self, ticket_id, component, timeout=5):
     127        self._merge(ticket_id, component, 'Merged .* to .* for', timeout)
     128
     129    def merge_conflict(self, ticket_id, component, timeout=5):
     130        self._merge(ticket_id, component, 'Found [0-9]+ conflicts? in attempt to merge ', timeout)
     131
     132    def _merge(self, ticket_id, component, search, timeout=5):
    127133        """timeout is in seconds."""
    128134        self.go_to_mergebot()
     
    132138        tc.find('Branch')
    133139        self.go_to_ticket(ticket_id)
    134         tc.find('Merged .* to .* for')
     140        tc.find(search)
    135141        # TODO: We may want to change this to remove the "dead" branch
    136142        retval = call(['svn', 'ls', self.repo_url + '/' + component + '/branches/ticket-%s' % ticket_id],
     
    294300
    295301
    296 class MergeBotTestCheckMerge(FunctionalTwillTestCaseSetup):
    297     def runTest(self):
    298         """Verify that the 'checkmerge' button works"""
    299         ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
    300             info={'component':'stuff', 'version':'trunk'})
    301         self._tester.branch(ticket_id, 'stuff')
    302         self._tester.checkmerge(ticket_id, 'stuff')
    303 
    304 
    305 class MergeBotTestRebranchWithChange(FunctionalSvnTestCaseSetup):
    306     def runTest(self):
    307         """Verify that the 'rebranch' button works with changes on the branch"""
     302class MergeBotTestMergeWithChange(FunctionalSvnTestCaseSetup):
     303    def runTest(self):
     304        """Verify that the 'merge' button works with changes on the branch"""
    308305        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
    309306            info={'component':'stuff', 'version':'trunk'})
     
    316313        self.commit('Add a new file')
    317314
    318         self._tester.rebranch(ticket_id, 'stuff')
    319 
    320 
    321 class MergeBotTestRebranchWithChangeAndTrunkChange(FunctionalSvnTestCaseSetup):
    322     def runTest(self):
    323         """Verify that the 'rebranch' button works with changes on the branch and trunk"""
     315        self._tester.merge(ticket_id, 'stuff')
     316
     317
     318class MergeBotTestMergeWithChangeAndTrunkChange(FunctionalSvnTestCaseSetup):
     319    def runTest(self):
     320        """Verify that the 'merge' button works with changes on the branch and trunk"""
    324321        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
    325322            info={'component':'stuff', 'version':'trunk'})
     
    336333        self.commit('Add a new file on trunk')
    337334
    338         self._tester.rebranch(ticket_id, 'stuff')
    339 
    340 
    341 class MergeBotTestRebranchWithConflict(FunctionalSvnTestCaseSetup):
    342     def runTest(self):
    343         """Verify that the 'rebranch' button works with conflicts on the branch and trunk"""
     335        self._tester.merge(ticket_id, 'stuff')
     336
     337
     338class MergeBotTestMergeWithConflict(FunctionalSvnTestCaseSetup):
     339    def runTest(self):
     340        """Verify that the 'merge' button detects conflicts between the branch and trunk"""
    344341        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
    345342            info={'component':'stuff', 'version':'trunk'})
     
    363360        self.commit('Modify the file on branch')
    364361
    365         # rebranch, make sure it shows a conflict
    366         self._tester.rebranch_conflict(ticket_id, 'stuff')
    367 
    368 
    369 class MergeBotTestRebranchWithBranchRenameConflict(FunctionalSvnTestCaseSetup):
    370     def runTest(self):
    371         """Verify that the 'rebranch' button works when a file renamed on the branch was modified on trunk"""
     362        # merge, make sure it shows a conflict
     363        self._tester.merge_conflict(ticket_id, 'stuff')
     364
     365
     366class MergeBotTestMergeWithBranchRenameConflict(FunctionalSvnTestCaseSetup):
     367    def runTest(self):
     368        """Verify that the 'merge' button detects a conflict when a file renamed on the branch was modified on trunk"""
    372369        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
    373370            info={'component':'stuff', 'version':'trunk'})
     
    391388        self.commit('Rename the file on the branch')
    392389
     390        self._tester.merge_conflict(ticket_id, 'stuff')
     391
     392
     393class MergeBotTestMergeWithTrunkRenameConflict(FunctionalSvnTestCaseSetup):
     394    def runTest(self):
     395        """Verify that the 'merge' button detects conflicts when a file renamed on trunk was modified on the branch"""
     396        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
     397            info={'component':'stuff', 'version':'trunk'})
     398        basename = self.__class__.__name__
     399
     400        # create a file in which to have conflicts
     401        self.checkout()
     402        self.add_new_file(basename)
     403        self.commit('Add a new file on trunk')
     404
     405        # create the branch
     406        self._tester.branch(ticket_id, 'stuff')
     407
     408        # rename the file on trunk
     409        self.mv(basename, basename + '-renamed')
     410        self.commit('Rename the file on trunk')
     411
     412        # rename the file on the branch
     413        self.switch(ticket_id)
     414        open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence())
     415        self.commit('Modify the file on the branch')
     416
     417        # make sure it finds the conflict
     418        self._tester.merge_conflict(ticket_id, 'stuff')
     419
     420
     421class MergeBotTestCheckMerge(FunctionalTwillTestCaseSetup):
     422    def runTest(self):
     423        """Verify that the 'checkmerge' button works"""
     424        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
     425            info={'component':'stuff', 'version':'trunk'})
     426        self._tester.branch(ticket_id, 'stuff')
     427        self._tester.checkmerge(ticket_id, 'stuff')
     428
     429
     430class MergeBotTestRebranchWithChange(FunctionalSvnTestCaseSetup):
     431    def runTest(self):
     432        """Verify that the 'rebranch' button works with changes on the branch"""
     433        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
     434            info={'component':'stuff', 'version':'trunk'})
     435        self._tester.branch(ticket_id, 'stuff')
     436
     437        # checkout a working copy & make a change
     438        self.checkout(ticket_id)
     439        # Create & add a new file
     440        self.add_new_file()
     441        self.commit('Add a new file')
     442
     443        self._tester.rebranch(ticket_id, 'stuff')
     444
     445
     446class MergeBotTestRebranchWithChangeAndTrunkChange(FunctionalSvnTestCaseSetup):
     447    def runTest(self):
     448        """Verify that the 'rebranch' button works with changes on the branch and trunk"""
     449        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
     450            info={'component':'stuff', 'version':'trunk'})
     451        self._tester.branch(ticket_id, 'stuff')
     452
     453        # checkout a working copy & make a change
     454        self.checkout(ticket_id)
     455        # Create & add a new file
     456        basename = self.__class__.__name__
     457        self.add_new_file(basename + '-ticket')
     458        self.commit('Add a new file on ticket')
     459        self.switch()
     460        self.add_new_file(basename + '-trunk')
     461        self.commit('Add a new file on trunk')
     462
     463        self._tester.rebranch(ticket_id, 'stuff')
     464
     465
     466class MergeBotTestRebranchWithConflict(FunctionalSvnTestCaseSetup):
     467    def runTest(self):
     468        """Verify that the 'rebranch' button detects conflicts between the branch and trunk"""
     469        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
     470            info={'component':'stuff', 'version':'trunk'})
     471        basename = self.__class__.__name__
     472
     473        # create a file in which to have conflicts
     474        self.checkout()
     475        self.add_new_file(basename)
     476        self.commit('Add a new file on trunk')
     477
     478        # create the branch
     479        self._tester.branch(ticket_id, 'stuff')
     480
     481        # modify the file on trunk
     482        open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence())
     483        self.commit('Modify the file on trunk')
     484
     485        # modify the file on the branch
     486        self.switch(ticket_id)
     487        open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence())
     488        self.commit('Modify the file on branch')
     489
     490        # rebranch, make sure it shows a conflict
    393491        self._tester.rebranch_conflict(ticket_id, 'stuff')
    394492
    395493
     494class MergeBotTestRebranchWithBranchRenameConflict(FunctionalSvnTestCaseSetup):
     495    def runTest(self):
     496        """Verify that the 'rebranch' button detects a conflict when a file renamed on the branch was modified on trunk"""
     497        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
     498            info={'component':'stuff', 'version':'trunk'})
     499        basename = self.__class__.__name__
     500
     501        # create a file in which to have conflicts
     502        self.checkout()
     503        self.add_new_file(basename)
     504        self.commit('Add a new file on trunk')
     505
     506        # create the branch
     507        self._tester.branch(ticket_id, 'stuff')
     508
     509        # modify the file on trunk
     510        open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence())
     511        self.commit('Modify the file on trunk')
     512
     513        # rename the file on the branch
     514        self.switch(ticket_id)
     515        self.mv(basename, basename + '-renamed')
     516        self.commit('Rename the file on the branch')
     517
     518        self._tester.rebranch_conflict(ticket_id, 'stuff')
     519
     520
    396521class MergeBotTestRebranchWithTrunkRenameConflict(FunctionalSvnTestCaseSetup):
    397522    def runTest(self):
    398         """Verify that the 'rebranch' button works when a file renamed on trunk was modified on the branch"""
     523        """Verify that the 'rebranch' button detects conflicts when a file renamed on trunk was modified on the branch"""
    399524        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
    400525            info={'component':'stuff', 'version':'trunk'})
     
    465590    suite.addTest(MergeBotTestRebranchWithBranchRenameConflict())
    466591    suite.addTest(MergeBotTestRebranchWithTrunkRenameConflict())
     592    suite.addTest(MergeBotTestMergeWithChange())
     593    suite.addTest(MergeBotTestMergeWithChangeAndTrunkChange())
     594    suite.addTest(MergeBotTestMergeWithConflict())
     595    suite.addTest(MergeBotTestMergeWithBranchRenameConflict())
     596    suite.addTest(MergeBotTestMergeWithTrunkRenameConflict())
    467597    suite.addTest(MergeBotTestSingleUseCase())
    468598    return suite
Note: See TracChangeset for help on using the changeset viewer.