Mercurial > hgsubversion
annotate tests/comprehensive/test_custom_layout.py @ 1541:adba152a5177
test_util: make developer warnings cause our tests to fail
Previously hgsubversion didn't get any help from develwarn calls,
because we don't use core's testrunner. The upstream configitem
refactor was easier to hunt down using the develwarn being a failure,
which prompted this code. It also exposed several locking correctness
bugs, so it feels like it's worth keeping around long term.
We don't bother with develwarn on anything so old that we don't try to
use smartset. The smartset deprecation was not handled gracefully, so
hg complains for many versions without actually breaking anything, and
it'd pointlessly complicate our code to handle smartset living in
multiple places between when the warning was introduced and the
present.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Sun, 29 Oct 2017 09:07:12 -0400 |
parents | 89997a5fc181 |
children |
rev | line source |
---|---|
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
1 import os |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
2 import sys |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
3 import unittest |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
4 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
5 from mercurial import hg |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
6 from mercurial import ui |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
7 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
8 # wrapped in a try/except because of weirdness in how |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
9 # run.py works as compared to nose. |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
10 try: |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
11 import test_util |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
12 except ImportError: |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
13 sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
14 import test_util |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
15 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
16 from hgsubversion import wrappers |
1365
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1342
diff
changeset
|
17 from hgsubversion import svnwrap |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
18 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
19 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
20 def _do_case(self, name, stupid): |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
21 subdir = test_util.subdir.get(name, '') |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
22 config = { |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
23 'hgsubversion.stupid': stupid and '1' or '0', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
24 } |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
25 repo, repo_path = self.load_and_fetch(name, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
26 subdir=subdir, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
27 layout='auto', |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
28 config=config) |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
29 assert test_util.repolen(self.repo) > 0, \ |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
30 'Repo had no changes, maybe you need to add a subdir entry in test_util?' |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
31 wc2_path = self.wc_path + '_custom' |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
32 checkout_path = repo_path |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
33 if subdir: |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
34 checkout_path += '/' + subdir |
1342
c6b01fd34694
trying to fix progress output
Augie Fackler <raf@durin42.com>
parents:
1133
diff
changeset
|
35 u = test_util.testui(stupid=stupid, layout='custom') |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
36 for branch, path in test_util.custom.get(name, {}).iteritems(): |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
37 u.setconfig('hgsubversionbranch', branch, path) |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
38 test_util.hgclone(u, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
39 test_util.fileurl(checkout_path), |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
40 wc2_path, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
41 update=False) |
1342
c6b01fd34694
trying to fix progress output
Augie Fackler <raf@durin42.com>
parents:
1133
diff
changeset
|
42 self.repo2 = hg.repository(test_util.testui(), wc2_path) |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
43 self.assertEqual(self.repo.heads(), self.repo2.heads()) |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
44 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
45 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
46 def buildmethod(case, name, stupid): |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
47 m = lambda self: self._do_case(case, stupid) |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
48 m.__name__ = name |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
49 replay = stupid and 'stupid' or 'regular' |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
50 m.__doc__ = 'Test custom produces same as standard on %s. (%s)' % (case, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
51 replay) |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
52 return m |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
53 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
54 attrs = {'_do_case': _do_case, |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
55 } |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
56 for case in test_util.custom: |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
57 name = 'test_' + case[:-len('.svndump')].replace('-', '_') |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
58 attrs[name] = buildmethod(case, name, stupid=False) |
1365
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1342
diff
changeset
|
59 if svnwrap.subversion_version < (1, 9, 0): |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1342
diff
changeset
|
60 name += '_stupid' |
89997a5fc181
stupid: self-disable if svn bindings are too new to work with stupid mode
Augie Fackler <raf@durin42.com>
parents:
1342
diff
changeset
|
61 attrs[name] = buildmethod(case, name, stupid=True) |
1092
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
62 |
cd0d14e25757
layouts: add custom layout for those of us that need weird mappings
David Schleimer <dschleimer@fb.com>
parents:
diff
changeset
|
63 CustomPullTests = type('CustomPullTests', (test_util.TestBase,), attrs) |