Mercurial > hg
annotate tests/test-manifest.py @ 24563:830280536946
json: implement {changeset} template
Output only contains basic changeset information for the moment. The
format is compatible with `hg log -Tjson`.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Tue, 31 Mar 2015 22:35:12 -0700 |
parents | bcf0de51326e |
children | 5491248e148a |
rev | line source |
---|---|
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
1 import binascii |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
2 import unittest |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
3 import itertools |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
4 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
5 import silenttestrunner |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
6 |
24225
3e5c4af69808
manifest: split manifestdict into high-level and low-level logic
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
7 from mercurial import manifest as manifestmod |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
8 from mercurial import match as matchmod |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
9 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
10 HASH_1 = '1' * 40 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
11 HASH_2 = 'f' * 40 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
12 HASH_3 = '1234567890abcdef0987654321deadbeef0fcafe' |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
13 A_SHORT_MANIFEST = ( |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
14 'bar/baz/qux.py\0%(hash2)s%(flag2)s\n' |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
15 'foo\0%(hash1)s%(flag1)s\n' |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
16 ) % {'hash1': HASH_1, |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
17 'flag1': '', |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
18 'hash2': HASH_2, |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
19 'flag2': 'l', |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
20 } |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
21 |
24549
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
22 A_DEEPER_MANIFEST = ( |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
23 'a/b/c/bar.py\0%(hash3)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
24 'a/b/c/bar.txt\0%(hash1)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
25 'a/b/c/foo.py\0%(hash3)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
26 'a/b/c/foo.txt\0%(hash2)s%(flag2)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
27 'a/b/d/baz.py\0%(hash3)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
28 'a/b/d/qux.py\0%(hash1)s%(flag2)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
29 'a/b/d/ten.txt\0%(hash3)s%(flag2)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
30 'a/b/dog.py\0%(hash3)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
31 'a/b/fish.py\0%(hash2)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
32 'a/c/london.py\0%(hash3)s%(flag2)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
33 'a/c/paper.txt\0%(hash2)s%(flag2)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
34 'a/c/paris.py\0%(hash2)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
35 'a/d/apple.py\0%(hash3)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
36 'a/d/pizza.py\0%(hash3)s%(flag2)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
37 'a/green.py\0%(hash1)s%(flag2)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
38 'a/purple.py\0%(hash2)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
39 'app.py\0%(hash3)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
40 'readme.txt\0%(hash2)s%(flag1)s\n' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
41 ) % {'hash1': HASH_1, |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
42 'flag1': '', |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
43 'hash2': HASH_2, |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
44 'flag2': 'l', |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
45 'hash3': HASH_3, |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
46 } |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
47 |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
48 HUGE_MANIFEST_ENTRIES = 200001 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
49 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
50 A_HUGE_MANIFEST = ''.join(sorted( |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
51 'file%d\0%s%s\n' % (i, h, f) for i, h, f in |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
52 itertools.izip(xrange(200001), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
53 itertools.cycle((HASH_1, HASH_2)), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
54 itertools.cycle(('', 'x', 'l'))))) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
55 |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
56 def parsemanifest(text): |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
57 return manifestmod.manifestdict(text) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
58 |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
59 class testmanifest(unittest.TestCase): |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
60 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
61 def assertIn(self, thing, container, msg=None): |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
62 # assertIn new in 2.7, use it if available, otherwise polyfill |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
63 sup = getattr(unittest.TestCase, 'assertIn', False) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
64 if sup: |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
65 return sup(self, thing, container, msg=msg) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
66 if not msg: |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
67 msg = 'Expected %r in %r' % (thing, container) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
68 self.assert_(thing in container, msg) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
69 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
70 def testEmptyManifest(self): |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
71 m = parsemanifest('') |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
72 self.assertEqual(0, len(m)) |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
73 self.assertEqual([], list(m)) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
74 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
75 def testManifest(self): |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
76 m = parsemanifest(A_SHORT_MANIFEST) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
77 self.assertEqual(['bar/baz/qux.py', 'foo'], list(m)) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
78 self.assertEqual(binascii.unhexlify(HASH_2), m['bar/baz/qux.py']) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
79 self.assertEqual('l', m.flags('bar/baz/qux.py')) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
80 self.assertEqual(binascii.unhexlify(HASH_1), m['foo']) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
81 self.assertEqual('', m.flags('foo')) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
82 self.assertRaises(KeyError, lambda : m['wat']) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
83 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
84 def testSetItem(self): |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
85 want = binascii.unhexlify(HASH_1) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
86 |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
87 m = parsemanifest('') |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
88 m['a'] = want |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
89 self.assertIn('a', m) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
90 self.assertEqual(want, m['a']) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
91 self.assertEqual('a\0' + HASH_1 + '\n', m.text()) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
92 |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
93 m = parsemanifest(A_SHORT_MANIFEST) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
94 m['a'] = want |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
95 self.assertEqual(want, m['a']) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
96 self.assertEqual('a\0' + HASH_1 + '\n' + A_SHORT_MANIFEST, |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
97 m.text()) |
24465
bb8e2b1a0803
test-manifest.py: separate out test for double-free after copy()
Martin von Zweigbergk <martinvonz@google.com>
parents:
24298
diff
changeset
|
98 |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
99 def testSetFlag(self): |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
100 want = 'x' |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
101 |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
102 m = parsemanifest('') |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
103 # first add a file; a file-less flag makes no sense |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
104 m['a'] = binascii.unhexlify(HASH_1) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
105 m.setflag('a', want) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
106 self.assertEqual(want, m.flags('a')) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
107 self.assertEqual('a\0' + HASH_1 + want + '\n', m.text()) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
108 |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
109 m = parsemanifest(A_SHORT_MANIFEST) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
110 # first add a file; a file-less flag makes no sense |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
111 m['a'] = binascii.unhexlify(HASH_1) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
112 m.setflag('a', want) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
113 self.assertEqual(want, m.flags('a')) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
114 self.assertEqual('a\0' + HASH_1 + want + '\n' + A_SHORT_MANIFEST, |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
115 m.text()) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
116 |
24465
bb8e2b1a0803
test-manifest.py: separate out test for double-free after copy()
Martin von Zweigbergk <martinvonz@google.com>
parents:
24298
diff
changeset
|
117 def testCopy(self): |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
118 m = parsemanifest(A_SHORT_MANIFEST) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
119 m['a'] = binascii.unhexlify(HASH_1) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
120 m2 = m.copy() |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
121 del m |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
122 del m2 # make sure we don't double free() anything |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
123 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
124 def testCompaction(self): |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
125 unhex = binascii.unhexlify |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
126 h1, h2 = unhex(HASH_1), unhex(HASH_2) |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
127 m = parsemanifest(A_SHORT_MANIFEST) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
128 m['alpha'] = h1 |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
129 m['beta'] = h2 |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
130 del m['foo'] |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
131 want = 'alpha\0%s\nbar/baz/qux.py\0%sl\nbeta\0%s\n' % ( |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
132 HASH_1, HASH_2, HASH_2) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
133 self.assertEqual(want, m.text()) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
134 self.assertEqual(3, len(m)) |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
135 self.assertEqual(['alpha', 'bar/baz/qux.py', 'beta'], list(m)) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
136 self.assertEqual(h1, m['alpha']) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
137 self.assertEqual(h2, m['bar/baz/qux.py']) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
138 self.assertEqual(h2, m['beta']) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
139 self.assertEqual('', m.flags('alpha')) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
140 self.assertEqual('l', m.flags('bar/baz/qux.py')) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
141 self.assertEqual('', m.flags('beta')) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
142 self.assertRaises(KeyError, lambda : m['foo']) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
143 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
144 def testSetGetNodeSuffix(self): |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
145 clean = parsemanifest(A_SHORT_MANIFEST) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
146 m = parsemanifest(A_SHORT_MANIFEST) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
147 h = m['foo'] |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
148 f = m.flags('foo') |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
149 want = h + 'a' |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
150 # Merge code wants to set 21-byte fake hashes at times |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
151 m['foo'] = want |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
152 self.assertEqual(want, m['foo']) |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
153 self.assertEqual([('bar/baz/qux.py', binascii.unhexlify(HASH_2)), |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
154 ('foo', binascii.unhexlify(HASH_1) + 'a')], |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
155 list(m.iteritems())) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
156 # Sometimes it even tries a 22-byte fake hash, but we can |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
157 # return 21 and it'll work out |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
158 m['foo'] = want + '+' |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
159 self.assertEqual(want, m['foo']) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
160 # make sure the suffix survives a copy |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
161 match = matchmod.match('', '', ['re:foo']) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
162 m2 = m.matches(match) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
163 self.assertEqual(want, m2['foo']) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
164 self.assertEqual(1, len(m2)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
165 m2 = m.copy() |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
166 self.assertEqual(want, m2['foo']) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
167 # suffix with iteration |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
168 self.assertEqual([('bar/baz/qux.py', binascii.unhexlify(HASH_2)), |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
169 ('foo', want)], |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
170 list(m.iteritems())) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
171 |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
172 # shows up in diff |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
173 self.assertEqual({'foo': ((want, f), (h, ''))}, m.diff(clean)) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
174 self.assertEqual({'foo': ((h, ''), (want, f))}, clean.diff(m)) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
175 |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
176 def testMatchException(self): |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
177 m = parsemanifest(A_SHORT_MANIFEST) |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
178 match = matchmod.match('', '', ['re:.*']) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
179 def filt(path): |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
180 if path == 'foo': |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
181 assert False |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
182 return True |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
183 match.matchfn = filt |
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
184 self.assertRaises(AssertionError, m.matches, match) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
185 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
186 def testRemoveItem(self): |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
187 m = parsemanifest(A_SHORT_MANIFEST) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
188 del m['foo'] |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
189 self.assertRaises(KeyError, lambda : m['foo']) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
190 self.assertEqual(1, len(m)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
191 self.assertEqual(1, len(list(m))) |
24228
542c891274b2
lazymanifest: use a binary search to do an insertion
Augie Fackler <augie@google.com>
parents:
24225
diff
changeset
|
192 # now restore and make sure everything works right |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
193 m['foo'] = 'a' * 20 |
24228
542c891274b2
lazymanifest: use a binary search to do an insertion
Augie Fackler <augie@google.com>
parents:
24225
diff
changeset
|
194 self.assertEqual(2, len(m)) |
542c891274b2
lazymanifest: use a binary search to do an insertion
Augie Fackler <augie@google.com>
parents:
24225
diff
changeset
|
195 self.assertEqual(2, len(list(m))) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
196 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
197 def testManifestDiff(self): |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
198 MISSING = (None, '') |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
199 addl = 'z-only-in-left\0' + HASH_1 + '\n' |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
200 addr = 'z-only-in-right\0' + HASH_2 + 'x\n' |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
201 left = parsemanifest( |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
202 A_SHORT_MANIFEST.replace(HASH_1, HASH_3 + 'x') + addl) |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
203 right = parsemanifest(A_SHORT_MANIFEST + addr) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
204 want = { |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
205 'foo': ((binascii.unhexlify(HASH_3), 'x'), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
206 (binascii.unhexlify(HASH_1), '')), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
207 'z-only-in-left': ((binascii.unhexlify(HASH_1), ''), MISSING), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
208 'z-only-in-right': (MISSING, (binascii.unhexlify(HASH_2), 'x')), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
209 } |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
210 self.assertEqual(want, left.diff(right)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
211 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
212 want = { |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
213 'bar/baz/qux.py': (MISSING, (binascii.unhexlify(HASH_2), 'l')), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
214 'foo': (MISSING, (binascii.unhexlify(HASH_3), 'x')), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
215 'z-only-in-left': (MISSING, (binascii.unhexlify(HASH_1), '')), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
216 } |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
217 self.assertEqual(want, parsemanifest('').diff(left)) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
218 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
219 want = { |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
220 'bar/baz/qux.py': ((binascii.unhexlify(HASH_2), 'l'), MISSING), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
221 'foo': ((binascii.unhexlify(HASH_3), 'x'), MISSING), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
222 'z-only-in-left': ((binascii.unhexlify(HASH_1), ''), MISSING), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
223 } |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
224 self.assertEqual(want, left.diff(parsemanifest(''))) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
225 copy = right.copy() |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
226 del copy['z-only-in-right'] |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
227 del right['foo'] |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
228 want = { |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
229 'foo': (MISSING, (binascii.unhexlify(HASH_1), '')), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
230 'z-only-in-right': ((binascii.unhexlify(HASH_2), 'x'), MISSING), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
231 } |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
232 self.assertEqual(want, right.diff(copy)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
233 |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
234 short = parsemanifest(A_SHORT_MANIFEST) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
235 pruned = short.copy() |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
236 del pruned['foo'] |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
237 want = { |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
238 'foo': ((binascii.unhexlify(HASH_1), ''), MISSING), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
239 } |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
240 self.assertEqual(want, short.diff(pruned)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
241 want = { |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
242 'foo': (MISSING, (binascii.unhexlify(HASH_1), '')), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
243 } |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
244 self.assertEqual(want, pruned.diff(short)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
245 want = { |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
246 'bar/baz/qux.py': None, |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
247 'foo': (MISSING, (binascii.unhexlify(HASH_1), '')), |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
248 } |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
249 self.assertEqual(want, pruned.diff(short, True)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
250 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
251 def testReversedLines(self): |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
252 backwards = ''.join( |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
253 l + '\n' for l in reversed(A_SHORT_MANIFEST.split('\n')) if l) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
254 try: |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
255 parsemanifest(backwards) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
256 self.fail('Should have raised ValueError') |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
257 except ValueError, v: |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
258 self.assertIn('Manifest lines not in sorted order.', str(v)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
259 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
260 def testNoTerminalNewline(self): |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
261 try: |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
262 parsemanifest(A_SHORT_MANIFEST + 'wat') |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
263 self.fail('Should have raised ValueError') |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
264 except ValueError, v: |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
265 self.assertIn('Manifest did not end in a newline.', str(v)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
266 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
267 def testNoNewLineAtAll(self): |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
268 try: |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
269 parsemanifest('wat') |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
270 self.fail('Should have raised ValueError') |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
271 except ValueError, v: |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
272 self.assertIn('Manifest did not end in a newline.', str(v)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
273 |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
274 def testHugeManifest(self): |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
275 m = parsemanifest(A_HUGE_MANIFEST) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
276 self.assertEqual(HUGE_MANIFEST_ENTRIES, len(m)) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
277 self.assertEqual(len(m), len(list(m))) |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
278 |
24549
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
279 def testMatchesMetadata(self): |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
280 '''Tests matches() for a few specific files to make sure that both |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
281 the set of files as well as their flags and nodeids are correct in |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
282 the resulting manifest.''' |
24466
f310ca66a704
test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents:
24465
diff
changeset
|
283 m = parsemanifest(A_HUGE_MANIFEST) |
24495
d2a3a2808974
manifest: make manifest.intersectfiles() internal
Drew Gottlieb <drgott@google.com>
parents:
24468
diff
changeset
|
284 |
d2a3a2808974
manifest: make manifest.intersectfiles() internal
Drew Gottlieb <drgott@google.com>
parents:
24468
diff
changeset
|
285 match = matchmod.match('/', '', |
d2a3a2808974
manifest: make manifest.intersectfiles() internal
Drew Gottlieb <drgott@google.com>
parents:
24468
diff
changeset
|
286 ['file1', 'file200', 'file300'], exact=True) |
d2a3a2808974
manifest: make manifest.intersectfiles() internal
Drew Gottlieb <drgott@google.com>
parents:
24468
diff
changeset
|
287 m2 = m.matches(match) |
d2a3a2808974
manifest: make manifest.intersectfiles() internal
Drew Gottlieb <drgott@google.com>
parents:
24468
diff
changeset
|
288 |
24225
3e5c4af69808
manifest: split manifestdict into high-level and low-level logic
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
289 w = ('file1\0%sx\n' |
3e5c4af69808
manifest: split manifestdict into high-level and low-level logic
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
290 'file200\0%sl\n' |
3e5c4af69808
manifest: split manifestdict into high-level and low-level logic
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
291 'file300\0%s\n') % (HASH_2, HASH_1, HASH_1) |
3e5c4af69808
manifest: split manifestdict into high-level and low-level logic
Augie Fackler <augie@google.com>
parents:
24214
diff
changeset
|
292 self.assertEqual(w, m2.text()) |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
293 |
24549
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
294 def testMatchesNonexistentFile(self): |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
295 '''Tests matches() for a small set of specific files, including one |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
296 nonexistent file to make sure in only matches against existing files. |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
297 ''' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
298 m = parsemanifest(A_DEEPER_MANIFEST) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
299 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
300 match = matchmod.match('/', '', |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
301 ['a/b/c/bar.txt', 'a/b/d/qux.py', 'readme.txt', 'nonexistent'], |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
302 exact=True) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
303 m2 = m.matches(match) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
304 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
305 self.assertEqual( |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
306 ['a/b/c/bar.txt', 'a/b/d/qux.py', 'readme.txt'], |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
307 m2.keys()) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
308 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
309 def testMatchesNonexistentDirectory(self): |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
310 '''Tests matches() for a relpath match on a directory that doesn't |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
311 actually exist.''' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
312 m = parsemanifest(A_DEEPER_MANIFEST) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
313 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
314 match = matchmod.match('/', '', ['a/f'], default='relpath') |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
315 m2 = m.matches(match) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
316 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
317 self.assertEqual([], m2.keys()) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
318 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
319 def testMatchesExactLarge(self): |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
320 '''Tests matches() for files matching a large list of exact files. |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
321 ''' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
322 m = parsemanifest(A_HUGE_MANIFEST) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
323 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
324 flist = m.keys()[80:300] |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
325 match = matchmod.match('/', '', flist, exact=True) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
326 m2 = m.matches(match) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
327 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
328 self.assertEqual(flist, m2.keys()) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
329 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
330 def testMatchesFull(self): |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
331 '''Tests matches() for what should be a full match.''' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
332 m = parsemanifest(A_DEEPER_MANIFEST) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
333 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
334 match = matchmod.match('/', '', ['']) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
335 m2 = m.matches(match) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
336 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
337 self.assertEqual(m.keys(), m2.keys()) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
338 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
339 def testMatchesDirectory(self): |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
340 '''Tests matches() on a relpath match on a directory, which should |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
341 match against all files within said directory.''' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
342 m = parsemanifest(A_DEEPER_MANIFEST) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
343 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
344 match = matchmod.match('/', '', ['a/b'], default='relpath') |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
345 m2 = m.matches(match) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
346 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
347 self.assertEqual([ |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
348 'a/b/c/bar.py', 'a/b/c/bar.txt', 'a/b/c/foo.py', 'a/b/c/foo.txt', |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
349 'a/b/d/baz.py', 'a/b/d/qux.py', 'a/b/d/ten.txt', 'a/b/dog.py', |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
350 'a/b/fish.py'], m2.keys()) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
351 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
352 def testMatchesExactPath(self): |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
353 '''Tests matches() on an exact match on a directory, which should |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
354 result in an empty manifest because you can't perform an exact match |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
355 against a directory.''' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
356 m = parsemanifest(A_DEEPER_MANIFEST) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
357 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
358 match = matchmod.match('/', '', ['a/b'], exact=True) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
359 m2 = m.matches(match) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
360 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
361 self.assertEqual([], m2.keys()) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
362 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
363 def testMatchesCwd(self): |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
364 '''Tests matches() on a relpath match with the current directory ('.') |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
365 when not in the root directory.''' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
366 m = parsemanifest(A_DEEPER_MANIFEST) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
367 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
368 match = matchmod.match('/', 'a/b', ['.'], default='relpath') |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
369 m2 = m.matches(match) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
370 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
371 self.assertEqual([ |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
372 'a/b/c/bar.py', 'a/b/c/bar.txt', 'a/b/c/foo.py', 'a/b/c/foo.txt', |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
373 'a/b/d/baz.py', 'a/b/d/qux.py', 'a/b/d/ten.txt', 'a/b/dog.py', |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
374 'a/b/fish.py'], m2.keys()) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
375 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
376 def testMatchesWithPattern(self): |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
377 '''Tests matches() for files matching a pattern that reside |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
378 deeper than the specified directory.''' |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
379 m = parsemanifest(A_DEEPER_MANIFEST) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
380 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
381 match = matchmod.match('/', '', ['a/b/*/*.txt']) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
382 m2 = m.matches(match) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
383 |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
384 self.assertEqual( |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
385 ['a/b/c/bar.txt', 'a/b/c/foo.txt', 'a/b/d/ten.txt'], |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
386 m2.keys()) |
bcf0de51326e
manifest: add some tests for manifest.matches()
Drew Gottlieb <drgott@google.com>
parents:
24495
diff
changeset
|
387 |
24214
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
388 if __name__ == '__main__': |
a5f1bccd2996
manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff
changeset
|
389 silenttestrunner.main(__name__) |