Changeset 64 for mergebot/trunk


Ignore:
Timestamp:
Feb 23, 2010 11:23:45 PM (15 years ago)
Author:
retracile
Message:

Mergebot: add another testcase, do some refactoring, and add some cleanup of working copies

File:
1 edited

Legend:

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

    r63 r64  
    55to be reworked to be less cumbersome.)
    66"""
     7
     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
    713
    814import os
     
    214220        self.assertEqual(retval, 0, "svn checkout failed with error %s" % (retval))
    215221
     222    def cleanup(self):
     223        shutil.rmtree(self.get_workdir())
     224
    216225    def switch(self, ticket_id=None):
    217226        if ticket_id is None:
     
    326335        self._tester.merge(ticket_id, 'stuff')
    327336
     337        self.cleanup()
    328338
    329339class MergeBotTestMergeWithChangeAndTrunkChange(FunctionalSvnTestCaseSetup):
     
    374384        self._tester.merge_conflict(ticket_id, 'stuff')
    375385
     386        self.cleanup()
     387
    376388
    377389class MergeBotTestMergeWithPropertyConflict(FunctionalSvnTestCaseSetup):
     
    401413        self._tester.merge_conflict(ticket_id, 'stuff')
    402414
     415        self.cleanup()
     416
    403417
    404418class MergeBotTestMergeWithPropertyBranchDeleteConflict(FunctionalSvnTestCaseSetup):
     
    428442        self._tester.merge_conflict(ticket_id, 'stuff')
    429443
     444        self.cleanup()
     445
    430446
    431447class MergeBotTestMergeWithPropertyTrunkDeleteConflict(FunctionalSvnTestCaseSetup):
     
    455471        self._tester.merge_conflict(ticket_id, 'stuff')
    456472
     473        self.cleanup()
     474
    457475
    458476class MergeBotTestMergeWithBranchRenameConflict(FunctionalSvnTestCaseSetup):
     
    481499
    482500        self._tester.merge_conflict(ticket_id, 'stuff')
     501
     502        self.cleanup()
    483503
    484504
     
    509529        # make sure it finds the conflict
    510530        self._tester.merge_conflict(ticket_id, 'stuff')
     531
     532        self.cleanup()
    511533
    512534
     
    534556
    535557        self._tester.rebranch(ticket_id, 'stuff')
     558        self.cleanup()
    536559
    537560
     
    554577
    555578        self._tester.rebranch(ticket_id, 'stuff')
     579        self.cleanup()
    556580
    557581
     
    582606        # rebranch, make sure it shows a conflict
    583607        self._tester.rebranch_conflict(ticket_id, 'stuff')
     608
     609        self.cleanup()
    584610
    585611
     
    610636        self._tester.rebranch_conflict(ticket_id, 'stuff')
    611637
     638        self.cleanup()
     639
    612640
    613641class MergeBotTestRebranchWithPropertyBranchDeleteConflict(FunctionalSvnTestCaseSetup):
     
    637665        self._tester.rebranch_conflict(ticket_id, 'stuff')
    638666
     667        self.cleanup()
     668
    639669
    640670class MergeBotTestRebranchWithPropertyTrunkDeleteConflict(FunctionalSvnTestCaseSetup):
     
    664694        self._tester.rebranch_conflict(ticket_id, 'stuff')
    665695
     696        self.cleanup()
     697
    666698
    667699class MergeBotTestRebranchWithBranchRenameConflict(FunctionalSvnTestCaseSetup):
     
    690722
    691723        self._tester.rebranch_conflict(ticket_id, 'stuff')
     724
     725        self.cleanup()
    692726
    693727
     
    719753        self._tester.rebranch_conflict(ticket_id, 'stuff')
    720754
    721 
    722 class MergeBotTestSingleUseCase(FunctionalTwillTestCaseSetup):
     755        self.cleanup()
     756
     757
     758class MergeBotTestSingleUseCase(FunctionalSvnTestCaseSetup):
    723759    def runTest(self):
    724760        """Create a branch, make a change, checkmerge, and merge it."""
     
    727763        self._tester.branch(ticket_id, 'stuff')
    728764        # checkout a working copy & make a change
    729         svnurl = self._testenv.repo_url()
    730         workdir = os.path.join(self._testenv.dirname, self.__class__.__name__)
    731         retval = call(['svn', 'checkout', svnurl + '/stuff/branches/ticket-%s' % ticket_id, workdir],
    732             stdout=logfile, stderr=logfile)
    733         self.assertEqual(retval, 0, "svn checkout failed with error %s" % (retval))
     765        self.checkout(ticket_id)
    734766        # Create & add a new file
    735         newfile = os.path.join(workdir, self.__class__.__name__)
    736         open(newfile, 'w').write(random_page())
    737         retval = call(['svn', 'add', self.__class__.__name__],
    738             cwd=workdir,
    739             stdout=logfile, stderr=logfile)
    740         self.assertEqual(retval, 0, "svn add failed with error %s" % (retval))
    741         retval = call(['svn', 'commit', '-m', 'Add a new file', self.__class__.__name__],
    742             cwd=workdir,
    743             stdout=logfile, stderr=logfile)
    744         self.assertEqual(retval, 0, "svn commit failed with error %s" % (retval))
    745 
     767        self.add_new_file()
     768        self.commit('Add a new file')
    746769        self._tester.checkmerge(ticket_id, 'stuff')
    747770        self._tester.merge(ticket_id, 'stuff')
    748 
    749         shutil.rmtree(workdir) # cleanup working copy
     771        self.cleanup()
     772
     773
     774class MergeBotTestBranchReuse(FunctionalSvnTestCaseSetup):
     775    def runTest(self):
     776        """Merge a branch, branch it again, and merge it a second time."""
     777        ticket_id = self._tester.create_ticket(summary=self.__class__.__name__,
     778            info={'component':'stuff', 'version':'trunk'})
     779        basename = self.__class__.__name__
     780
     781        self.checkout()
     782        self.add_new_file(basename)
     783        self.commit('Add a new file')
     784
     785        self._tester.branch(ticket_id, 'stuff')
     786        self.switch(ticket_id)
     787        open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence())
     788        self.commit('Make a modification')
     789        self._tester.merge(ticket_id, 'stuff')
     790
     791        self._tester.branch(ticket_id, 'stuff')
     792        self.switch(ticket_id)
     793        open(os.path.join(self.get_workdir(), basename), 'a').write(random_sentence())
     794        self.commit('Make a second modification')
     795        self._tester.merge(ticket_id, 'stuff')
     796        self.cleanup()
    750797
    751798
     
    775822    suite.addTest(MergeBotTestMergeWithPropertyTrunkDeleteConflict())
    776823    suite.addTest(MergeBotTestSingleUseCase())
     824    suite.addTest(MergeBotTestBranchReuse())
    777825    return suite
    778826
Note: See TracChangeset for help on using the changeset viewer.