Merge lp:~jelmer/bzr/per-workingtree-inventory-tests into lp:bzr

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Vincent Ladeuil
Approved revision: no longer in the source branch.
Merged at revision: 5821
Proposed branch: lp:~jelmer/bzr/per-workingtree-inventory-tests
Merge into: lp:bzr
Prerequisite: lp:~jelmer/bzr/per-workingtree-inventory-tests-pt1
Diff against target: 141 lines (+22/-26)
4 files modified
bzrlib/tests/__init__.py (+6/-4)
bzrlib/tests/per_workingtree/test_workingtree.py (+5/-7)
bzrlib/tests/test_commit.py (+8/-12)
bzrlib/tests/test_selftest.py (+3/-3)
To merge this branch: bzr merge lp:~jelmer/bzr/per-workingtree-inventory-tests
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Review via email: mp+58753@code.launchpad.net

This proposal supersedes a proposal from 2011-04-20.

Commit message

Skip tests that require an inventory when run against a WorkingTree that is not inventory based.

Description of the change

Skip tests that require an inventory when run against a WorkingTree that is not inventory based.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

sent to pqm by email

Revision history for this message
Vincent Ladeuil (vila) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/tests/__init__.py'
2--- bzrlib/tests/__init__.py 2011-04-18 00:44:08 +0000
3+++ bzrlib/tests/__init__.py 2011-04-21 20:55:55 +0000
4@@ -2125,18 +2125,20 @@
5 % (process_args, retcode, process.returncode))
6 return [out, err]
7
8- def check_inventory_shape(self, inv, shape):
9- """Compare an inventory to a list of expected names.
10+ def check_tree_shape(self, tree, shape):
11+ """Compare a tree to a list of expected names.
12
13 Fail if they are not precisely equal.
14 """
15 extras = []
16 shape = list(shape) # copy
17- for path, ie in inv.entries():
18+ for path, ie in tree.iter_entries_by_dir():
19 name = path.replace('\\', '/')
20 if ie.kind == 'directory':
21 name = name + '/'
22- if name in shape:
23+ if name == "/":
24+ pass # ignore root entry
25+ elif name in shape:
26 shape.remove(name)
27 else:
28 extras.append(name)
29
30=== modified file 'bzrlib/tests/per_workingtree/test_workingtree.py'
31--- bzrlib/tests/per_workingtree/test_workingtree.py 2011-04-21 20:55:54 +0000
32+++ bzrlib/tests/per_workingtree/test_workingtree.py 2011-04-21 20:55:55 +0000
33@@ -245,21 +245,19 @@
34 revid = b.revision_history()[0]
35 self.log('first revision_id is {%s}' % revid)
36
37- inv = b.repository.get_inventory(revid)
38- self.log('contents of inventory: %r' % inv.entries())
39+ tree = b.repository.revision_tree(revid)
40+ self.log('contents of tree: %r' % list(tree.iter_entries_by_dir()))
41
42- self.check_inventory_shape(inv,
43- ['dir/', 'dir/sub/', 'dir/sub/file'])
44+ self.check_tree_shape(tree, ['dir/', 'dir/sub/', 'dir/sub/file'])
45 wt.rename_one('dir', 'newdir')
46
47 wt.lock_read()
48- self.check_inventory_shape(wt.inventory,
49+ self.check_tree_shape(wt,
50 ['newdir/', 'newdir/sub/', 'newdir/sub/file'])
51 wt.unlock()
52 wt.rename_one('newdir/sub', 'newdir/newsub')
53 wt.lock_read()
54- self.check_inventory_shape(wt.inventory,
55- ['newdir/', 'newdir/newsub/',
56+ self.check_tree_shape(wt, ['newdir/', 'newdir/newsub/',
57 'newdir/newsub/file'])
58 wt.unlock()
59
60
61=== modified file 'bzrlib/tests/test_commit.py'
62--- bzrlib/tests/test_commit.py 2011-04-16 08:42:21 +0000
63+++ bzrlib/tests/test_commit.py 2011-04-21 20:55:55 +0000
64@@ -262,18 +262,16 @@
65 eq(tree1.id2path('hello-id'), 'hello')
66 eq(tree1.get_file_text('hello-id'), 'contents of hello\n')
67 self.assertFalse(tree1.has_filename('fruity'))
68- self.check_inventory_shape(tree1.inventory, ['hello'])
69- ie = tree1.inventory['hello-id']
70- eq(ie.revision, 'test@rev-1')
71+ self.check_tree_shape(tree1, ['hello'])
72+ eq(tree1.get_file_revision('hello-id'), 'test@rev-1')
73
74 tree2 = b.repository.revision_tree('test@rev-2')
75 tree2.lock_read()
76 self.addCleanup(tree2.unlock)
77 eq(tree2.id2path('hello-id'), 'fruity')
78 eq(tree2.get_file_text('hello-id'), 'contents of hello\n')
79- self.check_inventory_shape(tree2.inventory, ['fruity'])
80- ie = tree2.inventory['hello-id']
81- eq(ie.revision, 'test@rev-2')
82+ self.check_tree_shape(tree2, ['fruity'])
83+ eq(tree2.get_file_revision('hello-id'), 'test@rev-2')
84
85 def test_reused_rev_id(self):
86 """Test that a revision id cannot be reused in a branch"""
87@@ -300,8 +298,7 @@
88 wt.commit('two', rev_id=r2, allow_pointless=False)
89 wt.lock_read()
90 try:
91- self.check_inventory_shape(wt.read_working_inventory(),
92- ['a/', 'a/hello', 'b/'])
93+ self.check_tree_shape(wt, ['a/', 'a/hello', 'b/'])
94 finally:
95 wt.unlock()
96
97@@ -310,9 +307,9 @@
98 wt.commit('three', rev_id=r3, allow_pointless=False)
99 wt.lock_read()
100 try:
101- self.check_inventory_shape(wt.read_working_inventory(),
102+ self.check_tree_shape(wt,
103 ['a/', 'a/hello', 'a/b/'])
104- self.check_inventory_shape(b.repository.get_inventory(r3),
105+ self.check_tree_shape(b.repository.revision_tree(r3),
106 ['a/', 'a/hello', 'a/b/'])
107 finally:
108 wt.unlock()
109@@ -322,8 +319,7 @@
110 wt.commit('four', rev_id=r4, allow_pointless=False)
111 wt.lock_read()
112 try:
113- self.check_inventory_shape(wt.read_working_inventory(),
114- ['a/', 'a/b/hello', 'a/b/'])
115+ self.check_tree_shape(wt, ['a/', 'a/b/hello', 'a/b/'])
116 finally:
117 wt.unlock()
118
119
120=== modified file 'bzrlib/tests/test_selftest.py'
121--- bzrlib/tests/test_selftest.py 2011-04-15 07:01:22 +0000
122+++ bzrlib/tests/test_selftest.py 2011-04-21 20:55:55 +0000
123@@ -2810,16 +2810,16 @@
124 self.assertEqual(remaining_names, _test_ids(split_suite[1]))
125
126
127-class TestCheckInventoryShape(tests.TestCaseWithTransport):
128+class TestCheckTreeShape(tests.TestCaseWithTransport):
129
130- def test_check_inventory_shape(self):
131+ def test_check_tree_shape(self):
132 files = ['a', 'b/', 'b/c']
133 tree = self.make_branch_and_tree('.')
134 self.build_tree(files)
135 tree.add(files)
136 tree.lock_read()
137 try:
138- self.check_inventory_shape(tree.inventory, files)
139+ self.check_tree_shape(tree, files)
140 finally:
141 tree.unlock()
142