Changeset 1313 in tailor


Ignore:
Timestamp:
01/14/07 11:55:58 (6 years ago)
Author:
lele@…
Hash name:
20070114105558-97f81-b20eb47fcbaf2613c8ed7944763bcc2e6fb4db3c
Message:

Fetch darcs parser test cases from external files

Location:
vcpx/tests
Files:
8 added
1 edited
2 moved

Legend:

Unmodified
Added
Removed
  • vcpx/tests/darcs.py

    r1312 r1313  
    1515 
    1616 
    17 class DarcsChangesParser(TestCase): 
     17class DarcsParserTestCase(TestCase): 
     18 
     19    def getDarcsOutput(self, testname, ext='.log'): 
     20        from os.path import split, join 
     21 
     22        logfilename = join(split(__file__)[0], 'data', testname+ext) 
     23        return file(logfilename) 
     24 
     25         
     26class DarcsChangesParser(DarcsParserTestCase): 
    1827    """Tests for the parser of darcs changes""" 
    19  
    20     SIMPLE_TEST = """\ 
    21 <changelog> 
    22 <patch author='lele@nautilus.homeip.net' date='20040716123737' local_date='Fri Jul 16 14:37:37 CEST 2004' inverted='False' hash='20040716123737-97f81-9db0d923d2ba6f4c3808cb04a4ae4cf99fed185b.gz'> 
    23         <name>Fix the CVS parser to omit already seen changesets</name> 
    24         <comment>For some unknown reasons....</comment> 
    25  
    26     <summary> 
    27     <modify_file>vcpx/cvs.py<removed_lines num='4'/><added_lines num='11'/></modify_file> 
    28     <modify_file>vcpx/tests/cvs.py<removed_lines num='14'/><added_lines num='32'/></modify_file> 
    29     </summary> 
    30  
    31 </patch> 
    32  
    33 <patch author='lele@nautilus.homeip.net' date='20040601140559' local_date='Tue Jun  1 16:05:59 CEST 2004' inverted='False' hash='20040601140559-97f81-b669594864cb35290fbe4848e6645e73057a8caf.gz'> 
    34         <name>Svn log parser with test</name> 
    35  
    36     <summary> 
    37     <modify_file>cvsync/svn.py<removed_lines num='1'/><added_lines num='93'/></modify_file> 
    38     <modify_file>cvsync/tests/__init__.py<added_lines num='1'/></modify_file> 
    39     <add_file>cvsync/tests/svn.py</add_file> 
    40     <add_file>cvsync/tests/testrepo.dump</add_file> 
    41     </summary> 
    42  
    43 </patch> 
    44  
    45 </changelog> 
    46 """ 
    4728 
    4829    def testBasicBehaviour(self): 
    4930        """Verify basic darcs changes parser behaviour""" 
    5031 
    51         log = StringIO(self.SIMPLE_TEST) 
     32        log = self.getDarcsOutput('darcs-simple_test') 
    5233 
    5334        csets = changesets_from_darcschanges(log) 
     
    9980        self.assertEqual(head, 'Thu Jun  9 22:17:11 CEST 2005  zooko@zooko.com') 
    10081 
    101     ALL_ACTIONS_TEST = """\ 
    102 <changelog> 
    103 <patch author='' date='20050811140203' local_date='Thu Aug 11 16:02:03 CEST 2005' inverted='False' hash='20050811140203-da39a-0a36c886b2479b20ab9188781fe2e51f9a50a175.gz'> 
    104         <name>first</name> 
    105     <summary> 
    106     <add_file> 
    107     a.txt 
    108     </add_file> 
    109     <add_directory> 
    110     dir 
    111     </add_directory> 
    112     </summary> 
    113 </patch> 
    114 <patch author='' date='20050811140254' local_date='Thu Aug 11 16:02:54 CEST 2005' inverted='False' hash='20050811140254-da39a-b2ad279f1d7edae8e07b7b1ea8f3e63dbb242bf0.gz'> 
    115         <name>removed</name> 
    116     <summary> 
    117     <remove_directory> 
    118     dir 
    119     </remove_directory> 
    120     </summary> 
    121 </patch> 
    122 <patch author='' date='20050811140314' local_date='Thu Aug 11 16:03:14 CEST 2005' inverted='False' hash='20050811140314-da39a-de701bff466827b91e51658e411c768f43abc1b0.gz'> 
    123         <name>moved</name> 
    124     <summary> 
    125     <move from="bdir" to="dir"/> 
    126     <add_directory> 
    127     bdir 
    128     </add_directory> 
    129     </summary> 
    130 </patch> 
    131 <patch author='lele@metapensiero.it' date='20050811143245' local_date='Thu Aug 11 16:32:45 CEST 2005' inverted='False' hash='20050811143245-7a6fb-663bb3085e9b7996f554e4bd9d2f0b13208d65e0.gz'> 
    132         <name>modified</name> 
    133     <summary> 
    134     <modify_file> 
    135     a.txt<added_lines num='3'/> 
    136     </modify_file> 
    137     </summary> 
    138 </patch> 
    139 </changelog> 
    140 """ 
    141  
    14282    def testAllActions(self): 
    14383        """Verify darcs changes parser understand all actions""" 
    14484 
    145         log = StringIO(self.ALL_ACTIONS_TEST) 
     85        log = self.getDarcsOutput('darcs-all_actions_test') 
    14686 
    14787        csets = list(changesets_from_darcschanges(log)) 
     
    187127        """Verify that the parser is effectively incremental""" 
    188128 
    189         log = StringIO(self.ALL_ACTIONS_TEST) 
     129        log = self.getDarcsOutput('darcs-all_actions_test') 
    190130 
    191131        csets = list(changesets_from_darcschanges(log, chunksize=100)) 
    192132        self.assertEqual(len(csets), 4) 
    193133 
    194     OLD_DATE_FORMAT_TEST = """\ 
    195 <changelog> 
    196 <patch author='David Roundy &lt;droundy@abridgegame.org&gt;' date='Tue Oct 14 09:42:00 EDT 2003' local_date='Tue Oct 14 15:42:00 CEST 2003' inverted='False' hash='20031014094200-53a90-5896ac929692179d06a42af70f273800e4842603.gz'> 
    197         <name>use new select code in record.</name> 
    198 </patch> 
    199 <patch author='David Roundy &lt;droundy@abridgegame.org&gt;' date='20031014140231' local_date='Tue Oct 14 16:02:31 CEST 2003' inverted='False' hash='20031014140231-53a90-f5b6f441d32bd49d8ceacd6d804f31a462f94b88.gz'> 
    200         <name>use iso format for dates in record.</name> 
    201 </patch> 
    202 </changelog> 
    203 """ 
    204  
    205134    def testOldDateFormat(self): 
    206135        """Verify that the parser understands date format used by old darcs""" 
    207136 
    208         log = StringIO(self.OLD_DATE_FORMAT_TEST) 
     137        log = self.getDarcsOutput('darcs-old_date_format_test') 
    209138 
    210139        csets = changesets_from_darcschanges(log) 
     
    215144        cset = csets.next() 
    216145        self.assertEqual(cset.date, datetime(2003, 10, 14, 14, 2, 31, 0, UTC)) 
    217  
    218     RENAME_THEN_REMOVE_TEST = """ 
    219 <changelog> 
    220 <patch author='lele@nautilus.homeip.net' date='20060525213905' local_date='Thu May 25 23:39:05 CEST 2006' inverted='False' hash='20060525213905-97f81-292b84413dfdfca140fe104eb29273b50cb5701a.gz'> 
    221         <name>Move A to B and delete B</name> 
    222     <summary> 
    223     <move from="fileA" to="fileB"/> 
    224     <remove_file> 
    225     fileB 
    226     </remove_file> 
    227     </summary> 
    228 </patch> 
    229 </changelog> 
    230 """ 
    231146 
    232147    def testRenameAndRemove(self): 
    233148        """Verify that the parser degrades rename A B+remove B  to remove A""" 
    234149 
    235         log = StringIO(self.RENAME_THEN_REMOVE_TEST) 
     150        log = self.getDarcsOutput('darcs-rename_then_remove_test') 
    236151        csets = changesets_from_darcschanges(log) 
    237152 
     
    243158        self.assertEqual(entry.action_kind, entry.DELETED) 
    244159 
    245     BAD_XML_ORDER_TEST = """ 
    246 <changelog> 
    247 <patch author='robert.mcqueen@collabora.co.uk' date='20060121232733' local_date='Sun Jan 22 00:27:33 CET 2006' inverted='False' hash='20060121232733-0e791-01925e82713877d33452566a27eaad4184e287df.gz'> 
    248         <name>remove any possibility for darcs crack when moving from generated XML or generated source to the live tree, by putting the generated code in the live tree, and make whoever is doing the generation pull the changes over manually</name> 
    249     <summary> 
    250     <move from="tools/Makefile.am" to="generate/Makefile.am"/> 
    251     <move from="tools/generrors.py" to="generate/generrors.py"/> 
    252     <move from="tools/gengobject.py" to="generate/gengobject.py"/> 
    253     <move from="gabble-connection-manager.xml" to="generate/xml-modified/gabble-connection-manager.xml"/> 
    254     <move from="gabble-connection.xml" to="generate/xml-modified/gabble-connection.xml"/> 
    255     <move from="gabble-im-channel.xml" to="generate/xml-modified/gabble-im-channel.xml"/> 
    256     <move from="tools/README-do_gen" to="generate/README"/> 
    257     <move from="tools/do_gen.sh" to="generate/do_src.sh"/> 
    258     <move from="generate/added.sh" to="generate/added-then-renamed.sh"/> 
    259     <modify_file> 
    260     Makefile.am<removed_lines num='1'/><added_lines num='1'/> 
    261     </modify_file> 
    262     <add_directory> 
    263     generate 
    264     </add_directory> 
    265     <modify_file> 
    266     generate/README<removed_lines num='2'/><added_lines num='14'/> 
    267     </modify_file> 
    268     <modify_file> 
    269     generate/do_src.sh<removed_lines num='8'/><added_lines num='19'/> 
    270     </modify_file> 
    271     <add_file> 
    272     generate/do_xml.sh 
    273     </add_file> 
    274     <add_file> 
    275     generate/gabble.def 
    276     </add_file> 
    277     <remove_file> 
    278     generate/generrors.py 
    279     </remove_file> 
    280     <remove_file> 
    281     generate/gengobject.py 
    282     </remove_file> 
    283     <add_directory> 
    284     generate/src 
    285     </add_directory> 
    286     <add_file> 
    287     generate/src/gabble-connection-manager-signals-marshal.list 
    288     </add_file> 
    289     <add_file> 
    290     generate/src/gabble-connection-manager.c 
    291     </add_file> 
    292     <add_file> 
    293     generate/src/gabble-connection-manager.h 
    294     </add_file> 
    295     <add_file> 
    296     generate/src/gabble-connection-signals-marshal.list 
    297     </add_file> 
    298     <add_file> 
    299     generate/src/gabble-connection.c 
    300     </add_file> 
    301     <add_file> 
    302     generate/src/gabble-connection.h 
    303     </add_file> 
    304     <add_file> 
    305     generate/src/gabble-im-channel-signals-marshal.list 
    306     </add_file> 
    307     <add_file> 
    308     generate/src/gabble-im-channel.c 
    309     </add_file> 
    310     <add_file> 
    311     generate/src/gabble-im-channel.h 
    312     </add_file> 
    313     <add_file> 
    314     generate/src/telepathy-errors.h 
    315     </add_file> 
    316     <add_directory> 
    317     generate/xml-modified 
    318     </add_directory> 
    319     <add_directory> 
    320     generate/xml-pristine 
    321     </add_directory> 
    322     <add_file> 
    323     generate/xml-pristine/gabble-connection-manager.xml 
    324     </add_file> 
    325     <add_file> 
    326     generate/xml-pristine/gabble-connection.xml 
    327     </add_file> 
    328     <add_file> 
    329     generate/xml-pristine/gabble-im-channel.xml 
    330     </add_file> 
    331     <remove_directory> 
    332     tools 
    333     </remove_directory> 
    334     <add_file> 
    335     generate/added.sh 
    336     </add_file> 
    337     </summary> 
    338 </patch> 
    339 </changelog> 
    340 """ 
    341  
    342160    def testBadOrderedXML(self): 
    343161        "Verify if the parser is able to correct the bad order produced by changes --xml" 
    344162 
    345         log = StringIO(self.BAD_XML_ORDER_TEST) 
     163        log = self.getDarcsOutput('darcs-bad_xml_order_test') 
    346164        csets = changesets_from_darcschanges(log) 
    347165 
     
    357175                self.assertEqual(postadds, []) 
    358176 
    359     ADD_THEN_RENAME_TEST = """ 
    360 <changelog> 
    361 <patch author='ydirson@altern.org' date='20060702232916' local_date='Mon Jul  3 01:29:16 CEST 2006' inverted='False' hash='20060702232916-130f5-728038e54e0a59bb3567d8aa170610c2eaf370ff.gz'> 
    362         <name>[git] split git.py into source+target modules</name> 
    363         <comment> 
    364 This allows to get more accurate coverage stats.  Eg. my test tree now 
    365 exercises the git backend like: 
    366  
    367 Name                                  Stmts   Exec  Cover 
    368 --------------------------------------------------------- 
    369 vcpx/repository/git/__init__             44     37    84% 
    370 vcpx/repository/git/source               95      0     0% 
    371 vcpx/repository/git/target              154    115    74% 
    372 vcpx/target                             249    173    69%</comment> 
    373     <summary> 
    374     <move from="vcpx/repository/git.py" to="vcpx/repository/git/target.py"/> 
    375     <move from="vcpx/repository/git/core.py" to="vcpx/repository/git/__init__.py"/> 
    376     <add_directory> 
    377     vcpx/repository/git 
    378     </add_directory> 
    379     <modify_file> 
    380     vcpx/repository/git/__init__.py<added_lines num='81'/> 
    381     </modify_file> 
    382     <add_file> 
    383     vcpx/repository/git/core.py 
    384     </add_file> 
    385     <add_file> 
    386     vcpx/repository/git/source.py 
    387     </add_file> 
    388     <modify_file conflict='true'> 
    389     vcpx/repository/git/target.py<removed_lines num='12'/><added_lines num='7'/>    </modify_file> 
    390     </summary> 
    391 </patch> 
    392 </changelog> 
    393 """ 
    394  
    395     MIXED_TEST = """ 
    396 <changelog> 
    397 <patch author='esj@harvee.org' date='20050104213401' local_date='Tue Jan  4 22:34:01 CET 2005' inverted='False' hash='20050104213401-fab45-49c3d772521e523fa84be43883b235dbcbf9d61c.gz'> 
    398         <name>feedback and logging </name> 
    399         <comment>this patch has three major changes.  First is the addition of the 
    400 false negative feedback so that spam that leaks through 
    401 can be identified and corrected. 
    402  
    403 second is the logging changes minimizing information 
    404 dumped at the highest levels (1) in order to speed up message processing 
    405  
    406 third is updating portalocker for modern pythons. 
    407 </comment> 
    408     <summary> 
    409     <move from="ancillary/mbox2rpc.py" to="ancillary/fnsource.py"/> 
    410     <move from="ancillary/rpc2mbox.py" to="web-ui/cgi-exec/fnsink.py"/> 
    411     <modify_file> 
    412     ancillary/fnsource.py<added_lines num='335'/> 
    413     </modify_file> 
    414     <modify_file> 
    415     ancillary/global_configuration<added_lines num='8'/> 
    416     </modify_file> 
    417     <add_file> 
    418     ancillary/mbox2rpc.py 
    419     </add_file> 
    420     <modify_file> 
    421     ancillary/mbox2spamtrap.py<removed_lines num='1'/><added_lines num='1'/> 
    422     </modify_file> 
    423     <add_file> 
    424     ancillary/rpc2mbox.py 
    425     </add_file> 
    426     <modify_file> 
    427     modules/camram_email.py<removed_lines num='17'/><added_lines num='33'/> 
    428     </modify_file> 
    429     <modify_file> 
    430     modules/camram_utils.py<removed_lines num='2'/><added_lines num='5'/> 
    431     </modify_file> 
    432     <modify_file> 
    433     modules/configuration.py<removed_lines num='15'/><added_lines num='15'/> 
    434     </modify_file> 
    435     <modify_file> 
    436     modules/dbm_utils.py<removed_lines num='4'/><added_lines num='4'/> 
    437     </modify_file> 
    438     <modify_file> 
    439     modules/log.py<removed_lines num='1'/><added_lines num='1'/> 
    440     </modify_file> 
    441     <modify_file> 
    442     modules/portalocker.py<removed_lines num='2'/><added_lines num='2'/> 
    443     </modify_file> 
    444     <modify_file> 
    445     sgid/build.sh<removed_lines num='1'/><added_lines num='4'/> 
    446     </modify_file> 
    447     <modify_file> 
    448     src/core_filter.py<removed_lines num='50'/><added_lines num='55'/> 
    449     </modify_file> 
    450     <modify_file> 
    451     src/postfix_filter.py<removed_lines num='35'/><added_lines num='49'/> 
    452     </modify_file> 
    453     <modify_file> 
    454     src/postfix_stamper.py<removed_lines num='17'/><added_lines num='18'/> 
    455     </modify_file> 
    456     <modify_file> 
    457     web-ui/cgi-exec/correct.py<removed_lines num='17'/><added_lines num='17'/> 
    458     </modify_file> 
    459     <modify_file> 
    460     web-ui/cgi-exec/edit_config.py<removed_lines num='23'/><added_lines num='26'/> 
    461     </modify_file> 
    462     <modify_file> 
    463     web-ui/cgi-exec/fnsink.py<added_lines num='154'/> 
    464     </modify_file> 
    465     <modify_file> 
    466     web-ui/cgi-exec/recover.py<removed_lines num='5'/><added_lines num='5'/> 
    467     </modify_file> 
    468     <modify_file> 
    469     web-ui/cgi-exec/spamtrap_display.py<removed_lines num='4'/><added_lines num='4'/> 
    470     </modify_file> 
    471     <modify_file> 
    472     web-ui/templates/correct.html<removed_lines num='1'/><added_lines num='1'/> 
    473     </modify_file> 
    474     </summary> 
    475 </patch> 
    476 </changelog> 
    477 """ 
    478  
    479177    def testAddAndRename(self): 
    480178        "Verify if the parser degrades (add A)+(rename A B) to (add B)" 
    481179 
    482         log = StringIO(self.ADD_THEN_RENAME_TEST) 
     180        log = self.getDarcsOutput('darcs-add_then_rename_test') 
    483181        csets = changesets_from_darcschanges(log) 
    484182 
     
    489187        self.assertEqual(entry.action_kind, entry.ADDED) 
    490188 
    491         log = StringIO(self.MIXED_TEST) 
     189        log = self.getDarcsOutput('darcs-mixed_test') 
    492190        csets = changesets_from_darcschanges(log) 
    493191 
     
    496194        self.assertEqual([], [e for e in cset.entries if e.action_kind == e.RENAMED]) 
    497195 
    498     ADD_THEN_REMOVE_TEST = """ 
    499 <changelog> 
    500 <patch author='Erik Schnetter &lt;schnetter@aei.mpg.de&gt;' date='20050606193150' local_date='Mon Jun  6 21:31:50 CEST 2005' inverted='False' hash='20050606193150-891bb-dad36762ac41517fe0a9136ea14fff32b2930f0d.gz'> 
    501         <name>CarpetWeb: Update web pages</name> 
    502         <comment> 
    503 Update the web pages. 
    504 Explain stable and development versions better. 
    505 Update darcs binaries and documentation.</comment> 
    506     <summary> 
    507     <add_file> 
    508     Carpet/CarpetWeb/binaries/darcs-1.0.3-static-linux-i386.gz 
    509     </add_file> 
    510     <remove_file> 
    511     Carpet/CarpetWeb/binaries/darcs-1.0.3-static-linux-i386.gz 
    512     </remove_file> 
    513     <remove_file> 
    514     Carpet/CarpetWeb/doc/darcs-1.0.2.ps.gz 
    515     </remove_file> 
    516     <add_file> 
    517     Carpet/CarpetWeb/doc/darcs-1.0.3.ps.gz 
    518     </add_file> 
    519     <modify_file> 
    520     Carpet/CarpetWeb/get-carpet-darcs.html<removed_lines num='68'/><added_lines num='128'/> 
    521     </modify_file> 
    522     <modify_file> 
    523     Carpet/CarpetWeb/index.html<removed_lines num='56'/><added_lines num='17'/> 
    524     </modify_file> 
    525     <modify_file> 
    526     Carpet/CarpetWeb/olds.html<removed_lines num='1'/><added_lines num='22'/> 
    527     </modify_file> 
    528     <modify_file> 
    529     Carpet/CarpetWeb/work-with-darcs.html<removed_lines num='4'/><added_lines num='4'/> 
    530     </modify_file> 
    531     </summary> 
    532 </patch> 
    533 </changelog> 
    534 """ 
    535  
    536196    def testAddAndRemove(self): 
    537197        "Verify if the parser annihilate (add A)+(remove A)" 
    538198 
    539         log = StringIO(self.ADD_THEN_REMOVE_TEST) 
     199        log = self.getDarcsOutput('darcs-add_then_remove_test') 
    540200        csets = changesets_from_darcschanges(log) 
    541201 
     
    546206 
    547207 
    548 class DarcsPullParser(TestCase): 
     208class DarcsPullParser(DarcsParserTestCase): 
    549209    """Tests for the parser of darcs pull""" 
    550210 
     
    552212        """Verify basic darcs pull parser behaviour""" 
    553213 
    554         from os.path import split, join 
    555214        from vcpx.changes import Changeset 
    556215 
    557         logfilename = join(split(__file__)[0], 'data', 'darcs-pull.log') 
    558         output = file(logfilename) 
    559  
    560         hashfilename = join(split(__file__)[0], 'data', 'darcs-pull.hashes') 
    561         hashes = file(hashfilename) 
     216        output = self.getDarcsOutput('darcs-pull_parser_test') 
     217        hashes = self.getDarcsOutput('darcs-pull_parser_test', ext='.hashes') 
    562218 
    563219        class FauxRepository(object): 
Note: See TracChangeset for help on using the changeset viewer.