tests/test-manifest.py
author Martin von Zweigbergk <martinvonz@google.com>
Wed, 25 Mar 2015 14:13:46 -0700
changeset 24466 f310ca66a704
parent 24465 bb8e2b1a0803
child 24468 016b71ea7dc7
permissions -rw-r--r--
test-manifest.py: rewrite tests in terms of manifestdict By rewriting test-manifest.py in terms of manifestdict instead of _lazymanifest, the tests can be run on treemanifests too. There are still a few tests that fail on treemanifests. They will be addressed in the next few patches.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    22
HUGE_MANIFEST_ENTRIES = 200001
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    23
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    24
A_HUGE_MANIFEST = ''.join(sorted(
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    25
    '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
    26
    itertools.izip(xrange(200001),
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    27
                   itertools.cycle((HASH_1, HASH_2)),
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    28
                   itertools.cycle(('', 'x', 'l')))))
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    29
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    30
def parsemanifest(text):
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    31
    return manifestmod.manifestdict(text)
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    32
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    33
class testmanifest(unittest.TestCase):
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    34
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    35
    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
    36
        # 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
    37
        sup = getattr(unittest.TestCase, 'assertIn', False)
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    38
        if sup:
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    39
            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
    40
        if not msg:
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    41
            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
    42
        self.assert_(thing in container, msg)
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    43
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    44
    def testEmptyManifest(self):
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    45
        m = parsemanifest('')
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    46
        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
    47
        self.assertEqual([], list(m))
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    48
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    49
    def testManifest(self):
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    50
        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
    51
        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
    52
        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
    53
        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
    54
        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
    55
        self.assertEqual('', m.flags('foo'))
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    56
        self.assertRaises(KeyError, lambda : m['wat'])
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    57
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    58
    def testSetItem(self):
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    59
        want = binascii.unhexlify(HASH_1)
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    60
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    61
        m = parsemanifest('')
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    62
        m['a'] = want
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    63
        self.assertIn('a', m)
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    64
        self.assertEqual(want, m['a'])
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    65
        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
    66
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    67
        m = parsemanifest(A_SHORT_MANIFEST)
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    68
        m['a'] = want
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    69
        self.assertEqual(want, m['a'])
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    70
        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
    71
                         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
    72
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    73
    def testSetFlag(self):
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    74
        want = 'x'
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    75
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    76
        m = parsemanifest('')
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    77
        # 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
    78
        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
    79
        m.setflag('a', want)
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    80
        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
    81
        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
    82
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    83
        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
    84
        # 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
    85
        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
    86
        m.setflag('a', want)
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    87
        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
    88
        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
    89
                         m.text())
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    90
24465
bb8e2b1a0803 test-manifest.py: separate out test for double-free after copy()
Martin von Zweigbergk <martinvonz@google.com>
parents: 24298
diff changeset
    91
    def testCopy(self):
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
    92
        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
    93
        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
    94
        m2 = m.copy()
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    95
        del m
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    96
        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
    97
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    98
    def testCompaction(self):
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
    99
        unhex = binascii.unhexlify
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   100
        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
   101
        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
   102
        m['alpha'] = h1
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   103
        m['beta'] = h2
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   104
        del m['foo']
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   105
        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
   106
            HASH_1, HASH_2, HASH_2)
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   107
        self.assertEqual(want, m.text())
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   108
        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
   109
        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
   110
        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
   111
        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
   112
        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
   113
        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
   114
        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
   115
        self.assertEqual('', m.flags('beta'))
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   116
        self.assertRaises(KeyError, lambda : m['foo'])
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   117
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   118
    def testSetGetNodeSuffix(self):
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   119
        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
   120
        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
   121
        h = m['foo']
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   122
        f = m.flags('foo')
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   123
        want = h + 'a'
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   124
        # 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
   125
        m['foo'] = want
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   126
        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
   127
        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
   128
                          ('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
   129
                         list(m.iteritems()))
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   130
        # 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
   131
        # 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
   132
        m['foo'] = want + '+'
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   133
        self.assertEqual(want, m['foo'])
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   134
        # 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
   135
        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
   136
        m2 = m.matches(match)
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   137
        self.assertEqual(want, m2['foo'])
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   138
        self.assertEqual(1, len(m2))
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   139
        self.assertEqual(('foo\0%s\n' % HASH_1), m2.text())
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   140
        m2 = m.copy()
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   141
        self.assertEqual(want, m2['foo'])
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   142
        # suffix with iteration
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   143
        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
   144
                          ('foo', want)],
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   145
                         list(m.iteritems()))
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   146
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   147
        # 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
   148
        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
   149
        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
   150
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   151
    def testMatchException(self):
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   152
        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
   153
        match = matchmod.match('', '', ['re:.*'])
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   154
        def filt(path):
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   155
            if path == 'foo':
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   156
                assert False
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   157
            return True
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   158
        match.matchfn = filt
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   159
        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
   160
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   161
    def testRemoveItem(self):
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   162
        m = parsemanifest(A_SHORT_MANIFEST)
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   163
        del m['foo']
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   164
        self.assertRaises(KeyError, lambda : m['foo'])
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   165
        self.assertEqual(1, len(m))
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   166
        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
   167
        # 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
   168
        m['foo'] = 'a' * 20
24228
542c891274b2 lazymanifest: use a binary search to do an insertion
Augie Fackler <augie@google.com>
parents: 24225
diff changeset
   169
        self.assertEqual(2, len(m))
542c891274b2 lazymanifest: use a binary search to do an insertion
Augie Fackler <augie@google.com>
parents: 24225
diff changeset
   170
        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
   171
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   172
    def testManifestDiff(self):
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   173
        MISSING = (None, '')
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   174
        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
   175
        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
   176
        left = parsemanifest(
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   177
            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
   178
        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
   179
        want = {
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   180
            'foo': ((binascii.unhexlify(HASH_3), 'x'),
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   181
                    (binascii.unhexlify(HASH_1), '')),
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   182
            '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
   183
            '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
   184
            }
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   185
        self.assertEqual(want, left.diff(right))
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   186
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   187
        want = {
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   188
            '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
   189
            '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
   190
            '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
   191
            }
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   192
        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
   193
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   194
        want = {
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   195
            '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
   196
            '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
   197
            '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
   198
            }
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   199
        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
   200
        copy = right.copy()
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   201
        del copy['z-only-in-right']
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   202
        del right['foo']
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   203
        want = {
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   204
            'foo': (MISSING, (binascii.unhexlify(HASH_1), '')),
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   205
            '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
   206
            }
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   207
        self.assertEqual(want, right.diff(copy))
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   208
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   209
        short = parsemanifest(A_SHORT_MANIFEST)
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   210
        pruned = short.copy()
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   211
        del pruned['foo']
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
            'foo': ((binascii.unhexlify(HASH_1), ''), MISSING),
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   214
            }
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   215
        self.assertEqual(want, short.diff(pruned))
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   216
        want = {
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   217
            'foo': (MISSING, (binascii.unhexlify(HASH_1), '')),
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
        self.assertEqual(want, pruned.diff(short))
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   220
        want = {
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   221
            'bar/baz/qux.py': None,
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   222
            'foo': (MISSING, (binascii.unhexlify(HASH_1), '')),
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   223
            }
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   224
        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
   225
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   226
    def testReversedLines(self):
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   227
        backwards = ''.join(
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   228
            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
   229
        try:
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   230
            parsemanifest(backwards)
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   231
            self.fail('Should have raised ValueError')
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   232
        except ValueError, v:
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   233
            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
   234
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   235
    def testNoTerminalNewline(self):
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   236
        try:
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   237
            parsemanifest(A_SHORT_MANIFEST + 'wat')
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   238
            self.fail('Should have raised ValueError')
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   239
        except ValueError, v:
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   240
            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
   241
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   242
    def testNoNewLineAtAll(self):
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   243
        try:
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   244
            parsemanifest('wat')
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   245
            self.fail('Should have raised ValueError')
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   246
        except ValueError, v:
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   247
            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
   248
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   249
    def testHugeManifest(self):
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   250
        m = parsemanifest(A_HUGE_MANIFEST)
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   251
        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
   252
        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
   253
24225
3e5c4af69808 manifest: split manifestdict into high-level and low-level logic
Augie Fackler <augie@google.com>
parents: 24214
diff changeset
   254
    def testIntersectFiles(self):
24466
f310ca66a704 test-manifest.py: rewrite tests in terms of manifestdict
Martin von Zweigbergk <martinvonz@google.com>
parents: 24465
diff changeset
   255
        m = parsemanifest(A_HUGE_MANIFEST)
24225
3e5c4af69808 manifest: split manifestdict into high-level and low-level logic
Augie Fackler <augie@google.com>
parents: 24214
diff changeset
   256
        m2 = m.intersectfiles(['file1', 'file200', 'file300'])
3e5c4af69808 manifest: split manifestdict into high-level and low-level logic
Augie Fackler <augie@google.com>
parents: 24214
diff changeset
   257
        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
   258
             'file200\0%sl\n'
3e5c4af69808 manifest: split manifestdict into high-level and low-level logic
Augie Fackler <augie@google.com>
parents: 24214
diff changeset
   259
             '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
   260
        self.assertEqual(w, m2.text())
24214
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   261
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   262
if __name__ == '__main__':
a5f1bccd2996 manifest.c: new extension code to lazily parse manifests
Augie Fackler <augie@google.com>
parents:
diff changeset
   263
    silenttestrunner.main(__name__)