Dan Villiom Podlaski Christiansen avatar Dan Villiom Podlaski Christiansen committed d3ff580

fold test_startrev and test_verify into a new test; test_verify_and_startrev

Comments (0)

Files changed (5)

tests/comprehensive/test_verify.py

-import os
-import pickle
-import sys
-import unittest
-
-# wrapped in a try/except because of weirdness in how
-# run.py works as compared to nose.
-try:
-    import test_util
-except ImportError:
-    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
-    import test_util
-
-from mercurial import hg
-from mercurial import ui
-
-from hgsubversion import svncommands
-
-def _do_case(self, name, stupid, layout):
-    subdir = test_util.subdir.get(name, '')
-    repo = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid, layout=layout)
-    assert len(self.repo) > 0
-    for i in repo:
-        ctx = repo[i]
-        self.assertEqual(svncommands.verify(repo.ui, repo, rev=ctx.node()), 0)
-
-def buildmethod(case, name, stupid, layout):
-    m = lambda self: self._do_case(case, stupid, layout)
-    m.__name__ = name
-    bits = case, stupid and 'stupid' or 'real', layout
-    m.__doc__ = 'Test verify on %s with %s replay. (%s)' % bits
-    return m
-
-attrs = {'_do_case': _do_case}
-fixtures = [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]
-for case in fixtures:
-    # this fixture results in an empty repository, don't use it
-    if case == 'project_root_not_repo_root.svndump':
-        continue
-    bname = 'test_' + case[:-len('.svndump')]
-    attrs[bname] = buildmethod(case, bname, False, 'standard')
-    name = bname + '_stupid'
-    attrs[name] = buildmethod(case, name, True, 'standard')
-    name = bname + '_single'
-    attrs[name] = buildmethod(case, name, False, 'single')
-    # Disabled because the "stupid and real are the same" tests
-    # verify this plus even more.
-    # name = bname + '_single_stupid'
-    # attrs[name] = buildmethod(case, name, True, 'single')
-
-VerifyTests = type('VerifyTests', (test_util.TestBase,), attrs)
-
-def suite():
-    all_tests = [unittest.TestLoader().loadTestsFromTestCase(VerifyTests)]
-    return unittest.TestSuite(all_tests)

tests/comprehensive/test_verify_and_startrev.py

+import os
+import pickle
+import sys
+import unittest
+
+# wrapped in a try/except because of weirdness in how
+# run.py works as compared to nose.
+try:
+    import test_util
+except ImportError:
+    sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
+    import test_util
+
+from mercurial import hg
+from mercurial import ui
+
+from hgsubversion import svncommands
+
+# these fixtures contain no files at HEAD and would result in empty clones
+_skipshallow = set([
+    'binaryfiles.svndump',
+    'binaryfiles-broken.svndump',
+    'emptyrepo.svndump',
+])
+
+def _do_case(self, name, stupid, layout):
+    subdir = test_util.subdir.get(name, '')
+    repo, svnpath = self.load_and_fetch(name, subdir=subdir, stupid=stupid,
+                                        layout=layout)
+    assert len(self.repo) > 0
+    for i in repo:
+        ctx = repo[i]
+        self.assertEqual(svncommands.verify(repo.ui, repo, rev=ctx.node()), 0)
+
+    # check a startrev clone
+    if layout == 'single' and name not in _skipshallow:
+        self.wc_path += '_shallow'
+        shallowrepo = self.fetch(svnpath, subdir=subdir, stupid=stupid,
+                                 layout='single', startrev='HEAD')
+
+        self.assertEqual(len(shallowrepo), 1,
+                         "shallow clone should have just one revision, not %d"
+                         % len(shallowrepo))
+
+        fulltip = repo['tip']
+        shallowtip = shallowrepo['tip']
+
+        self.assertEqual(0, svncommands.verify(repo.ui, shallowrepo,
+                                               rev=shallowtip.node()))
+
+        # viewing diff's of lists of files is easier on the eyes
+        self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(shallowtip))
+
+        for f in fulltip:
+            self.assertMultiLineEqual(fulltip[f].data(), shallowtip[f].data())
+
+
+def buildmethod(case, name, stupid, layout):
+    m = lambda self: self._do_case(case, stupid, layout)
+    m.__name__ = name
+    bits = case, stupid and 'stupid' or 'real', layout
+    m.__doc__ = 'Test verify on %s with %s replay. (%s)' % bits
+    return m
+
+attrs = {'_do_case': _do_case}
+fixtures = [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]
+for case in fixtures:
+    # this fixture results in an empty repository, don't use it
+    if case == 'project_root_not_repo_root.svndump':
+        continue
+    bname = 'test_' + case[:-len('.svndump')]
+    attrs[bname] = buildmethod(case, bname, False, 'standard')
+    name = bname + '_stupid'
+    attrs[name] = buildmethod(case, name, True, 'standard')
+    name = bname + '_single'
+    attrs[name] = buildmethod(case, name, False, 'single')
+    # Disabled because the "stupid and real are the same" tests
+    # verify this plus even more.
+    # name = bname + '_single_stupid'
+    # attrs[name] = buildmethod(case, name, True, 'single')
+
+VerifyTests = type('VerifyTests', (test_util.TestBase,), attrs)
+
+def suite():
+    all_tests = [unittest.TestLoader().loadTestsFromTestCase(VerifyTests)]
+    return unittest.TestSuite(all_tests)
     import test_push_eol
     import test_rebuildmeta
     import test_single_dir_clone
-    import test_startrev
     import test_svnwrap
     import test_tags
     import test_template_keywords
     sys.path.append(os.path.join(os.path.dirname(__file__), 'comprehensive'))
 
     import test_stupid_pull
-    import test_verify
+    import test_verify_and_startrev
 
     return locals()
 

tests/test_startrev.py

-import test_util
-
-import os
-import unittest
-
-def _do_case(self, name, subdir, stupid):
-    wc_base = self.wc_path
-    self.wc_path = wc_base + '_full'
-    headclone = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid,
-                                             layout='single', startrev='HEAD')
-    self.wc_path = wc_base + '_head'
-    fullclone = self._load_fixture_and_fetch(name, subdir=subdir, stupid=stupid,
-                                             layout='single')
-
-    fulltip = fullclone['tip']
-    headtip = headclone['tip']
-    # viewing diff's of lists of files is easier on the eyes
-    self.assertMultiLineEqual('\n'.join(fulltip), '\n'.join(headtip))
-
-    for f in fulltip:
-        self.assertMultiLineEqual(fulltip[f].data(), headtip[f].data())
-
-    self.assertNotEqual(len(fullclone), 0, "full clone shouldn't be empty")
-    self.assertEqual(len(headclone), 1,
-                     "shallow clone should have just one revision, not %d"
-                     % len(headclone))
-
-def buildmethod(case, name, subdir, stupid):
-    m = lambda self: self._do_case(case, subdir.strip('/'), stupid)
-    m.__name__ = name
-    m.__doc__ = ('Test clone with startrev on %s%s with %s replay.' %
-                 (case, subdir, (stupid and 'stupid') or 'real'))
-    return m
-
-
-# these fixtures contain no files at HEAD and would result in empty clones
-nofiles = set([
-    'binaryfiles.svndump',
-    'binaryfiles-broken.svndump',
-    'emptyrepo.svndump',
-])
-
-# these fixtures contain no files in trunk at HEAD and would result in an empty
-# shallow clone if cloning trunk, so we use another subdirectory
-subdirmap = {
-    'commit-to-tag.svndump': '/branches/magic',
-    'pushexternals.svndump': '',
-    'tag_name_same_as_branch.svndump': '/branches/magic',
-}
-
-attrs = {'_do_case': _do_case,
-         }
-
-for case in [f for f in os.listdir(test_util.FIXTURES) if f.endswith('.svndump')]:
-    if case in nofiles:
-        continue
-
-    subdir = test_util.subdir.get(case, '') + subdirmap.get(case, '/trunk')
-
-    bname = 'test_' + case[:-len('.svndump')]
-    attrs[bname] = buildmethod(case, bname, subdir, False)
-    name = bname + '_stupid'
-    attrs[name] = buildmethod(case, name, subdir, True)
-
-StartRevTests = type('StartRevTests', (test_util.TestBase,), attrs)
-
-
-def suite():
-    all_tests = [unittest.TestLoader().loadTestsFromTestCase(StartRevTests),
-          ]
-    return unittest.TestSuite(all_tests)

tests/test_util.py

         proc.communicate()
         return path
 
-    def load_and_fetch(self, fixture_name, subdir=None, stupid=False,
-                       layout='auto', startrev=0, externals=None,
-                       noupdate=True):
+    def fetch(self, repo_path, subdir=None, stupid=False, layout='auto', startrev=0,
+              externals=None, noupdate=True, dest=None):
         if layout == 'single':
             if subdir is None:
                 subdir = 'trunk'
         elif subdir is None:
             subdir = ''
-        repo_path = self.load_svndump(fixture_name)
         projectpath = repo_path
         if subdir:
             projectpath += '/' + subdir
 
         dispatch(cmd)
 
-        return hg.repository(testui(), self.wc_path), repo_path
+        return hg.repository(testui(), self.wc_path)
+
+    def load_and_fetch(self, fixture_name, *args, **opts):
+        repo_path = self.load_svndump(fixture_name)
+
+        return self.fetch(repo_path, *args, **opts), repo_path
 
     def _load_fixture_and_fetch(self, *args, **kwargs):
         repo, repo_path = self.load_and_fetch(*args, **kwargs)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.