Changeset 882 in tailor


Ignore:
Timestamp:
10/06/05 01:20:46 (8 years ago)
Author:
lele@…
Hash name:
20051005232046-97f81-a428e84c397d7e458a784e40f3316a2c2c070055
Message:

Reorganization of the test suite

  • Dropped "Test" from test names
  • Added an option --list get the available tests
  • Splitted the too heavy operational test into smaller suites
  • Added bazaar-ng source backend test
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • tailor

    r850 r882  
    2222    locale.setlocale(locale.LC_CTYPE, '') 
    2323    if len(sys.argv)>1 and sys.argv[1] == 'test': 
    24         del sys.argv[1] 
    25         from unittest import main 
    26         main(module='vcpx.tests', argv=sys.argv) 
     24        from vcpx.tests import main 
     25        main() 
    2726    else: 
    2827        from vcpx import * 
  • vcpx/tests/__init__.py

    r729 r882  
    55# :Licenza:  GNU General Public License 
    66# 
     7 
     8import sys 
     9from unittest import TestProgram, TestSuite 
    710 
    811from shwrap import * 
     
    1720 
    1821ExternalCommand.VERBOSE = False 
     22 
     23class TailorTest(TestProgram): 
     24    """A command-line program that runs a set of tests; this is primarily 
     25       for making test modules conveniently executable. 
     26    """ 
     27    USAGE = """\ 
     28Usage: %(progName)s [options] [test] [...] 
     29 
     30Options: 
     31  -h, --help       Show this message 
     32  -v, --verbose    Verbose output 
     33  -q, --quiet      Minimal output 
     34  -l, --list       List available tests without running them 
     35 
     36Examples: 
     37  %(progName)s                               - run default set of tests 
     38  %(progName)s MyTestSuite                   - run suite 'MyTestSuite' 
     39  %(progName)s MyTestCase.testSomething      - run MyTestCase.testSomething 
     40  %(progName)s MyTestCase                    - run all 'test*' test methods 
     41                                               in MyTestCase 
     42""" 
     43 
     44    def __init__(self): 
     45        del sys.argv[1] 
     46        TestProgram.__init__(self, module='vcpx.tests', argv=sys.argv) 
     47 
     48    def parseArgs(self, argv): 
     49        import getopt 
     50        try: 
     51            options, args = getopt.getopt(argv[1:], 'hHvql', 
     52                                          ['help','verbose','quiet','list']) 
     53            listonly = False 
     54            for opt, value in options: 
     55                if opt in ('-h','-H','--help'): 
     56                    self.usageExit() 
     57                if opt in ('-q','--quiet'): 
     58                    self.verbosity = 0 
     59                if opt in ('-v','--verbose'): 
     60                    self.verbosity = 2 
     61                if opt in ('-l','--list'): 
     62                    listonly = True 
     63            if len(args) == 0 and self.defaultTest is None: 
     64                self.test = self.testLoader.loadTestsFromModule(self.module) 
     65            else: 
     66                if len(args) > 0: 
     67                    self.testNames = args 
     68                else: 
     69                    self.testNames = (self.defaultTest,) 
     70                self.createTests() 
     71            if listonly: 
     72                def listsuite(suite): 
     73                    tcount = 0 
     74                    scount = 0 
     75                    tclass = None 
     76                    for t in suite._tests: 
     77                        if isinstance(t, TestSuite): 
     78                            tc,sc = listsuite(t) 
     79                            tcount += tc 
     80                            scount += sc + 1 
     81                        else: 
     82                            tcount += 1 
     83                            if tclass <> t.__class__: 
     84                                tclass = t.__class__ 
     85                                title = tclass.__name__ 
     86                                if tclass.__doc__: 
     87                                    title += ': ' + tclass.__doc__.strip() 
     88                                print 
     89                                print title 
     90                                print '='*len(title) 
     91                            print t._TestCase__testMethodName, '--', 
     92                            print t.shortDescription() 
     93                    return tcount, scount 
     94                tcount, scount = listsuite(self.test) 
     95                print 
     96                print "%d tests in %d suites" % (tcount,scount) 
     97                sys.exit(0) 
     98        except getopt.error, msg: 
     99            self.usageExit(msg) 
     100 
     101main = TailorTest 
  • vcpx/tests/shwrap.py

    r594 r882  
    66# 
    77 
    8 from unittest import TestCase, TestSuite 
     8from unittest import TestCase 
    99from vcpx.shwrap import ExternalCommand, PIPE, STDOUT 
    1010 
    11 class SystemCommandTest(TestCase): 
    12     """Perform some basic tests of the wrapper. 
    13     """ 
     11class SystemCommand(TestCase): 
     12    """Perform some basic tests of the wrapper""" 
    1413 
    1514    def testExitStatusForTrue(self): 
  • vcpx/tests/cvsps.py

    r670 r882  
    66#  
    77 
    8 from unittest import TestCase, TestSuite 
     8from unittest import TestCase 
    99from datetime import datetime 
    1010from StringIO import StringIO 
    1111from vcpx.cvsps import changesets_from_cvsps 
    1212 
    13 class CvspsParserTest(TestCase): 
    14     """Ensure the cvsps parser does its job.""" 
     13class CvspsParser(TestCase): 
     14    """Ensure the cvsps parser does its job""" 
    1515 
    1616    SIMPLE_TEST = """\ 
  • vcpx/tests/cvs.py

    r866 r882  
    66# 
    77 
    8 from unittest import TestCase, TestSuite 
     8from unittest import TestCase 
    99from datetime import datetime 
    1010from StringIO import StringIO 
    1111from vcpx.cvs import changesets_from_cvslog, CvsEntry 
    1212 
    13 class CvsEntryTest(TestCase): 
     13class CvsEntry(TestCase): 
    1414    """Tests for the CvsEntry class""" 
    1515 
     
    4141 
    4242 
    43 class CvsLogParserTest(TestCase): 
    44     """Ensure the cvs log parser does its job.""" 
     43class CvsLogParser(TestCase): 
     44    """Ensure the cvs log parser does its job""" 
    4545 
    4646    SIMPLE_TEST = u"""\ 
  • vcpx/tests/darcs.py

    r594 r882  
    66# 
    77 
    8 from unittest import TestCase, TestSuite 
     8from unittest import TestCase 
    99from datetime import datetime 
    1010from StringIO import StringIO 
     
    1212from shwrap import ExternalCommand, PIPE 
    1313 
    14 class DarcsChangesParserTest(TestCase): 
     14class DarcsChangesParser(TestCase): 
    1515    """Tests for the parser of darcs changes""" 
    1616 
  • vcpx/tests/svn.py

    r840 r882  
    66# 
    77 
    8 from unittest import TestCase, TestSuite 
     8from unittest import TestCase 
    99from datetime import datetime 
    1010from StringIO import StringIO 
    1111from vcpx.svn import changesets_from_svnlog 
    1212 
    13 class SvnLogParserTest(TestCase): 
    14     """Ensure the svn log parser does its job.""" 
     13class SvnLogParser(TestCase): 
     14    """Ensure the svn log parser does its job""" 
    1515 
    1616    SIMPLE_RENAME_TEST = """\ 
  • README

    r879 r882  
    9595======= 
    9696 
    97 You can run the test suite with the following command line:: 
     97Tailor has more than 50 unit and operational tests, that you can 
     98run with the following command line:: 
    9899 
    99100 $ tailor test -v 
    100101 
    101 that runs all the tests in sequence, or:: 
    102  
    103  $ tailor test -v TailorTest 
    104  
    105 to trigger just a subset of them. 
     102Since some tests take very long to complete, in particular the 
     103operational tests, you may prefer the execution of a single suite:: 
     104 
     105 $ tailor test -v Darcs 
     106 
     107or even a single test within a suite:: 
     108 
     109 $ tailor test StateFile.testJournal 
     110 
     111To obtain a list of the test, use ``--list`` option.  As usual with:: 
     112 
     113 $ tailor test --help 
     114 
     115you will get some more details. 
    106116 
    107117 
  • vcpx/tests/config.py

    r831 r882  
    66# 
    77 
    8 from unittest import TestCase, TestSuite 
     8from unittest import TestCase 
    99from cStringIO import StringIO 
    1010from vcpx.config import Config, ConfigurationError 
    1111from vcpx.project import Project 
    1212 
    13 class ConfigTest(TestCase): 
     13class Config(TestCase): 
     14    "Test the configuration system" 
    1415 
    1516    def setUp(self): 
  • vcpx/tests/tailor.py

    r806 r882  
    2323verbose = True 
    2424state-file = tailor.state 
    25 start-revision = Version 0.9.7 
     25start-revision = Version 0.9.16 
    2626 
    2727[darcs2bzr] 
     
    2929root-directory = /tmp/tailor-tests/darcs2bzr 
    3030source = darcs:tailor 
    31  
    32 [darcs2bzrng] 
    33 target = bzrng:tailor 
    34 root-directory = /tmp/tailor-tests/darcs2bzrng 
    35 source = darcs:tailor 
    3631patch-name-format = %(revision)s 
     32 
     33[bzr2darcs] 
     34source = bzr:tailor 
     35root-directory = /tmp/tailor-tests/bzr2darcs 
     36target = darcs:bzrtailor 
     37patch-name-format = %(revision)s 
     38 
     39[darcs:tailor] 
     40 
     41[bzr:tailor] 
     42python-path = /opt/src/bzr.dev 
     43 
    3744 
    3845[darcs2cdv] 
     
    4148source = darcs:tailor 
    4249 
     50[cdv:tailor] 
     51 
     52 
    4353[darcs2hg] 
    4454target = hg:tailor 
    4555root-directory = /tmp/tailor-tests/darcs2hg 
    4656source = darcs:tailor 
     57 
     58[hg:tailor] 
     59 
    4760 
    4861[darcs2svn] 
     
    5871start-revision = 1 
    5972 
     73[svn:tailor] 
     74repository = file:///tmp/tailor-tests/svnrepo 
     75module = tailor 
     76subdir = svnside 
     77use-propset = True 
     78 
     79[darcs:svntailor] 
     80subdir = darcside 
     81 
     82 
    6083[darcs2monotone] 
    6184target = monotone:tailor 
     
    6891target = darcs:mtntailor 
    6992start-revision = INITIAL 
    70  
    71 [darcs:tailor] 
    72  
    73 [bzr:tailor] 
    74 bzr-command = /opt/src/bzr.dev/bzr 
    75  
    76 [bzrng:tailor] 
    77 python-path = /opt/src/bzr.dev 
    78  
    79 [cdv:tailor] 
    80  
    81 [hg:tailor] 
    8293 
    8394[monotone:tailor] 
     
    90101subdir = darcside 
    91102 
    92 [svn:tailor] 
    93 repository = file:///tmp/tailor-tests/svnrepo 
    94 module = tailor 
    95 subdir = svnside 
    96 use-propset = True 
    97  
    98 [darcs:svntailor] 
    99 subdir = darcside 
    100103 
    101104[cvs2darcs] 
     
    113116encoding = iso-8859-1 
    114117 
     118 
    115119[cvs2hglib] 
    116120root-directory = /tmp/tailor-tests/cvs2hglib 
     
    126130 
    127131[hglib:cmsmini] 
     132 
    128133 
    129134[cvs2bzr] 
     
    139144 
    140145[bzr:atse] 
    141 bzr-command = /opt/src/bzr.dev/bzr 
     146python-path = /opt/src/bzr.dev 
     147 
    142148 
    143149[svndump2darcs] 
     
    155161subdir = . 
    156162 
     163 
    157164[svndump2hg] 
    158165source = svndump:pyobjc 
     
    167174[hg:pyobjc] 
    168175subdir = hg 
     176 
    169177 
    170178[svndump2hg-partial] 
     
    183191subdir = hg 
    184192 
     193 
    185194[cvs2svn] 
    186195source = cvs:cmfeditions-houston-sprint 
     
    206215""" 
    207216 
    208 from unittest import TestCase, TestSuite 
     217from unittest import TestCase 
    209218from cStringIO import StringIO 
    210219from vcpx.config import Config 
     
    212221from vcpx.shwrap import ExternalCommand, PIPE 
    213222 
    214 class TailorTest(TestCase): 
     223class OperationalTest(TestCase): 
    215224 
    216225    def setUp(self): 
     
    228237        if not exists('/tmp/tailor-tests'): 
    229238            mkdir('/tmp/tailor-tests') 
    230             register(rmtree, '/tmp/tailor-tests') 
     239            #register(rmtree, '/tmp/tailor-tests') 
    231240 
    232241    def diffWhenPossible(self, tailorizer): 
     
    247256            return "" 
    248257 
     258    def tailorize(self, project): 
     259        "The actual test" 
     260 
     261        tailorizer = Tailorizer(project, self.config) 
     262        self.assert_(not tailorizer.exists()) 
     263        tailorizer() 
     264        self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     265 
     266class Darcs(OperationalTest): 
     267    "Test darcs backend" 
     268 
    249269    def testConfiguration(self): 
    250270        "Test basic configuration" 
     
    265285        self.assertEqual(tailorizer.source.subdir, 'pxlib') 
    266286 
    267     def testDarcsToBazaarng(self): 
    268         "Test darcs to BazaarNG" 
    269  
    270         tailorizer = Tailorizer('darcs2bzr', self.config) 
    271         self.assert_(not tailorizer.exists()) 
    272         tailorizer() 
    273         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
    274  
    275     def testDarcsToBazaarngNative(self): 
    276         "Test darcs to BazaarNG (native)" 
    277  
    278         tailorizer = Tailorizer('darcs2bzrng', self.config) 
    279         self.assert_(not tailorizer.exists()) 
    280         tailorizer() 
    281         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     287    def testDarcsAndBazaarng(self): 
     288        "Test darcs to bazaar-ng and the other way around" 
     289 
     290        self.tailorize('darcs2bzr') 
     291        self.tailorize('bzr2darcs') 
    282292 
    283293    def testDarcsToMercurial(self): 
    284294        "Test darcs to mercurial" 
    285295 
    286         tailorizer = Tailorizer('darcs2hg', self.config) 
    287         self.assert_(not tailorizer.exists()) 
    288         tailorizer() 
    289         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     296        self.tailorize('darcs2hg') 
    290297 
    291298    def testDarcsToCodeville(self): 
    292299        "Test darcs to codeville" 
    293300 
    294         tailorizer = Tailorizer('darcs2cdv', self.config) 
    295         self.assert_(not tailorizer.exists()) 
    296         tailorizer() 
    297         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
    298  
    299     def testDarcsToSubversion(self): 
    300         "Test darcs to subversion" 
    301  
    302         tailorizer = Tailorizer('darcs2svn', self.config) 
    303         self.assert_(not tailorizer.exists()) 
    304         tailorizer() 
    305         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
    306  
    307     def testDarcsToMonotone(self): 
    308         "Test darcs to monotone" 
    309  
    310         tailorizer = Tailorizer('darcs2monotone', self.config) 
    311         self.assert_(not tailorizer.exists()) 
    312         tailorizer() 
    313         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
    314  
    315     ## The other way 
    316  
    317     def testSubversionToDarcs(self): 
    318         "Test subversion to darcs" 
    319  
    320         tailorizer = Tailorizer('svn2darcs', self.config) 
    321         self.assert_(not tailorizer.exists()) 
    322         tailorizer() 
    323         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     301        self.tailorize('darcs2cdv') 
     302 
     303    def testDarcsAndSubversion(self): 
     304        "Test darcs to subversion and the other way around" 
     305 
     306        self.tailorize('darcs2svn') 
     307        self.tailorize('svn2darcs') 
     308 
     309    def testDarcsAndMonotone(self): 
     310        "Test darcs to monotone and the other way around" 
     311 
     312        self.tailorize('darcs2monotone') 
     313        self.tailorize('monotone2darcs') 
     314 
     315 
     316class Cvs(OperationalTest): 
     317    "Test the CVS source backend" 
    324318 
    325319    def testCvsToDarcs(self): 
    326320        "Test CVS to darcs" 
    327321 
    328         tailorizer = Tailorizer('cvs2darcs', self.config) 
    329         self.assert_(not tailorizer.exists()) 
    330         tailorizer() 
    331         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     322        self.tailorize('cvs2darcs') 
    332323 
    333324    def testCvsToMercurial(self): 
    334         "Test CVS to Mercurial" 
    335  
    336         tailorizer = Tailorizer('cvs2hglib', self.config) 
    337         self.assert_(not tailorizer.exists()) 
    338         tailorizer() 
    339         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     325        "Test CVS to mercurial" 
     326 
     327        self.tailorize('cvs2hglib') 
    340328 
    341329    def testCvsToBazaarng(self): 
    342         "Test CVS to Bazaar-NG" 
    343  
    344         tailorizer = Tailorizer('cvs2bzr', self.config) 
    345         self.assert_(not tailorizer.exists()) 
    346         tailorizer() 
    347         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     330        "Test CVS to bazaar-ng" 
     331 
     332        self.tailorize('cvs2bzr') 
    348333 
    349334    def testCvsToSubversion(self): 
    350335        "Test CVS branch to Subversion" 
    351336 
    352         tailorizer = Tailorizer('cvs2svn', self.config) 
    353         self.assert_(not tailorizer.exists()) 
    354         tailorizer() 
    355         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     337        self.tailorize('cvs2svn') 
     338 
     339 
     340class Svndump(OperationalTest): 
     341    "Test the svndump source backend (deprecated)" 
    356342 
    357343    def testSvndumpToDarcs(self): 
    358344        "Test subversion dump to darcs" 
    359345 
    360         tailorizer = Tailorizer('svndump2darcs', self.config) 
    361         self.assert_(not tailorizer.exists()) 
    362         tailorizer() 
    363         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     346        self.tailorize('svndump2darcs') 
    364347 
    365348    def testSvndumpToMercurial(self): 
    366349        "Test subversion dump to mercurial" 
    367350 
    368         tailorizer = Tailorizer('svndump2hg', self.config) 
    369         self.assert_(not tailorizer.exists()) 
    370         tailorizer() 
    371         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     351        self.tailorize('svndump2hg') 
    372352 
    373353    def testPartialSvndumpToMercurial(self): 
    374354        "Test partial subversion dump to mercurial" 
    375355 
    376         tailorizer = Tailorizer('svndump2hg-partial', self.config) 
    377         self.assert_(not tailorizer.exists()) 
    378         tailorizer() 
    379         self.assertEqual(self.diffWhenPossible(tailorizer), "") 
     356        self.tailorize('svndump2hg-partial') 
  • vcpx/tests/statefile.py

    r679 r882  
    66# 
    77 
    8 from unittest import TestCase, TestSuite 
     8from unittest import TestCase 
    99from cStringIO import StringIO 
    1010from vcpx.statefile import StateFile 
    1111from vcpx.shwrap import ReopenableNamedTemporaryFile 
    1212 
    13 class StateFileTest(TestCase): 
     13class Statefile(TestCase): 
     14    "Exercise the state file machinery" 
    1415 
    1516    def testStateFile(self): 
  • vcpx/tests/svndump.py

    r755 r882  
    66# 
    77 
    8 from unittest import TestCase, TestSuite 
     8from unittest import TestCase 
    99from datetime import datetime 
    1010from StringIO import StringIO 
    1111from vcpx.svndump import changesets_from_svndump 
    1212 
    13 class SvndumpParserTest(TestCase): 
    14     """Ensure the svndump parser does its job.""" 
     13class SvndumpParser(TestCase): 
     14    """Ensure the svndump parser does its job""" 
    1515 
    1616    def setUp(self): 
Note: See TracChangeset for help on using the changeset viewer.