annotate tests/comprehensive/test_sqlite_revmap.py @ 1512:6d0fe7ce9898

commands: fix command option registering A recent patch introduced svnopts as a way of sharing the svn command options between the old and the new way of registering a command. It turns out 'svnopts' was already used further up in the module to define the flags that should be added to *all* Mercurial commands. So our definition of it here cause us to add all of these options to all Mercurial commands. This was caught because it changes --rev to be '' instead of [], which breaks a number of assumptions in the other commands. Given that none of the subversion tests are command line tests, I'm not sure how to test this. It was caught in other extensions tests. (grafted from 3b1334407783a4379fd515e2ed9acc61e3f175ff) (grafted from 6db63ead5556f2bf72e423ca8c6df08ea3a5b009)
author Durham Goode <durham@fb.com>
date Wed, 24 May 2017 15:07:00 -0700
parents f21605bcda24
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1474
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
1 import os
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
2 import unittest
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
3 import sys
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
4
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
5 # wrapped in a try/except because of weirdness in how
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
6 # run.py works as compared to nose.
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
7 try:
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
8 import test_util
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
9 except ImportError:
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
10 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
11 import test_util
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
12
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
13 # interesting and fast tests
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
14 import test_fetch_mappings
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
15 import test_fetch_renames
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
16 import test_pull
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
17 import test_template_keywords
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
18 import test_utility_commands
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
19
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
20 # comprehensive tests
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
21 try:
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
22 import test_custom_layout
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
23 except ImportError:
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
24 sys.path.insert(0, os.path.dirname(__file__))
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
25 import test_custom_layout
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
26
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
27 import test_rebuildmeta
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
28 import test_updatemeta
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
29
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
30 from hgsubversion import svnmeta, maps
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
31
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
32
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
33 class SqliteRevMapMixIn(object):
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
34 # do not double the test size by being wrapped again
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
35 obsolete_mode_tests = False
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
36 stupid_mode_tests = False
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
37
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
38 def setUp(self):
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
39 assert svnmeta.SVNMeta._defaultrevmapclass is maps.RevMap
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
40 svnmeta.SVNMeta._defaultrevmapclass = maps.SqliteRevMap
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
41 super(SqliteRevMapMixIn, self).setUp()
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
42
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
43 def tearDown(self):
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
44 assert svnmeta.SVNMeta._defaultrevmapclass is maps.SqliteRevMap
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
45 svnmeta.SVNMeta._defaultrevmapclass = maps.RevMap
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
46 super(SqliteRevMapMixIn, self).tearDown()
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
47
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
48 def shortDescription(self):
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
49 text = super(SqliteRevMapMixIn, self).shortDescription()
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
50 if text:
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
51 text += ' (sqlite revmap)'
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
52 return text
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
53
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
54 def buildtestclass(cls, selector=None):
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
55 name = 'SqliteRevMap%s' % cls.__name__
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
56 newcls = type(name, (SqliteRevMapMixIn, cls,), {})
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
57
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
58 # remove test cases not selected by selector
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
59 if selector:
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
60 for name in dir(newcls):
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
61 if name.startswith('test_') and not selector(name[5:]):
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
62 setattr(newcls, name, None)
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
63
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
64 globals()[name] = newcls
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
65
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
66 def svndumpselector(name):
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
67 return name in ['branch_rename_to_trunk',
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
68 'tag_name_same_as_branch']
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
69
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
70 buildtestclass(test_fetch_mappings.MapTests)
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
71 buildtestclass(test_fetch_renames.TestFetchRenames)
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
72 buildtestclass(test_pull.TestPull)
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
73 buildtestclass(test_template_keywords.TestLogKeywords)
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
74 buildtestclass(test_utility_commands.UtilityTests)
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
75
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
76 buildtestclass(test_rebuildmeta.RebuildMetaTests, svndumpselector)
f21605bcda24 tests: add the sqlite revmap test
Jun Wu <quark@fb.com>
parents:
diff changeset
77 buildtestclass(test_updatemeta.UpdateMetaTests, svndumpselector)