Merge lp:~jelmer/brz/skip-inventory into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: no longer in the source branch.
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/skip-inventory
Merge into: lp:brz
Diff against target: 164 lines (+33/-24)
2 files modified
breezy/tests/per_workingtree/test_basis_inventory.py (+9/-0)
breezy/tests/per_workingtree/test_executable.py (+24/-24)
To merge this branch: bzr merge lp:~jelmer/brz/skip-inventory
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+340637@code.launchpad.net

Commit message

Skip over some more inventory-specific stuff in tests for foreign branches.

Description of the change

Fix some more tests for foreign branches:

* Avoid passing in explicit revision ids
* Skip inventory-specific tests
* Use tree API rather than inventory where possible

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Thanks!

review: Approve
Revision history for this message
The Breezy Bot (the-breezy-bot) wrote :

Running landing tests failed
https://ci.breezy-vcs.org/job/brz-dev/9/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/tests/per_workingtree/test_basis_inventory.py'
2--- breezy/tests/per_workingtree/test_basis_inventory.py 2017-08-07 19:09:47 +0000
3+++ breezy/tests/per_workingtree/test_basis_inventory.py 2018-03-06 00:26:30 +0000
4@@ -33,6 +33,10 @@
5
6 # Make sure the basis file is created by a commit
7 t = self.make_branch_and_tree('.')
8+ if getattr(t, 'root_inventory', None) is None:
9+ raise TestNotApplicable("not applicable to %r"
10+ % (self.workingtree_format,))
11+
12 b = t.branch
13 with open('a', 'wb') as f: f.write('a\n')
14 t.add('a')
15@@ -68,6 +72,11 @@
16 raise TestNotApplicable("not applicable to %r"
17 % (self.workingtree_format,))
18 t = self.make_branch_and_tree('.')
19+ if getattr(t, 'root_inventory', None) is None:
20+ raise TestNotApplicable("not applicable to %r"
21+ % (self.workingtree_format,))
22+
23+
24 b = t.branch
25 with open('a', 'wb') as f: f.write('a\n')
26 t.add('a')
27
28=== modified file 'breezy/tests/per_workingtree/test_executable.py'
29--- breezy/tests/per_workingtree/test_executable.py 2017-11-12 14:19:13 +0000
30+++ breezy/tests/per_workingtree/test_executable.py 2018-03-06 00:26:30 +0000
31@@ -56,7 +56,7 @@
32 the inventory is empty, just that the tree doesn't have them
33 """
34 tree.lock_read()
35- if not ignore_inv:
36+ if not ignore_inv and getattr(tree, 'root_inventory', None):
37 self.assertEqual(
38 [('', tree.root_inventory.root)],
39 list(tree.root_inventory.iter_entries()))
40@@ -68,14 +68,14 @@
41
42 def commit_and_branch(self):
43 """Commit the current tree, and create a second tree"""
44- self.wt.commit('adding a,b', rev_id='r1')
45+ r1 = self.wt.commit('adding a,b')
46 # Now make sure that 'bzr branch' also preserves the
47 # executable bit
48- dir2 = self.wt.branch.controldir.sprout('b2', revision_id='r1')
49+ dir2 = self.wt.branch.controldir.sprout('b2', revision_id=r1)
50 wt2 = dir2.open_workingtree()
51- self.assertEqual(['r1'], wt2.get_parent_ids())
52- self.assertEqual('r1', wt2.branch.last_revision())
53- return wt2
54+ self.assertEqual([r1], wt2.get_parent_ids())
55+ self.assertEqual(r1, wt2.branch.last_revision())
56+ return wt2, r1
57
58 def test_01_is_executable(self):
59 """Make sure that the tree was created and has the executable bit set"""
60@@ -88,14 +88,14 @@
61
62 def test_03_after_commit(self):
63 """Commit the change, and check the history"""
64- self.wt.commit('adding a,b', rev_id='r1')
65+ r1 = self.wt.commit('adding a,b')
66
67- rev_tree = self.wt.branch.repository.revision_tree('r1')
68+ rev_tree = self.wt.branch.repository.revision_tree(r1)
69 self.check_exist(rev_tree)
70
71 def test_04_after_removed(self):
72 """Make sure reverting removed files brings them back correctly"""
73- self.wt.commit('adding a,b', rev_id='r1')
74+ r1 = self.wt.commit('adding a,b')
75
76 # Make sure the entries are gone
77 os.remove('b1/a')
78@@ -105,24 +105,24 @@
79 # Make sure that revert is able to bring them back,
80 # and sets 'a' back to being executable
81
82- rev_tree = self.wt.branch.repository.revision_tree('r1')
83+ rev_tree = self.wt.branch.repository.revision_tree(r1)
84
85 self.wt.revert(['a', 'b'], rev_tree, backups=False)
86 self.check_exist(self.wt)
87
88 def test_05_removed_and_committed(self):
89 """Check that reverting to an earlier commit restores them"""
90- self.wt.commit('adding a,b', rev_id='r1')
91+ r1 = self.wt.commit('adding a,b')
92
93 # Now remove them again, and make sure that after a
94 # commit, they are still marked correctly
95 os.remove('b1/a')
96 os.remove('b1/b')
97- self.wt.commit('removed', rev_id='r2')
98+ r2 = self.wt.commit('removed')
99
100 self.check_empty(self.wt)
101
102- rev_tree = self.wt.branch.repository.revision_tree('r1')
103+ rev_tree = self.wt.branch.repository.revision_tree(r1)
104 # Now revert back to the previous commit
105 self.wt.revert(old_tree=rev_tree, backups=False)
106
107@@ -131,38 +131,38 @@
108 def test_06_branch(self):
109 """branch b1=>b2 should preserve the executable bits"""
110 # TODO: Maybe this should be a blackbox test
111- wt2 = self.commit_and_branch()
112+ wt2, r1 = self.commit_and_branch()
113
114 self.check_exist(wt2)
115
116 def test_07_pull(self):
117 """Test that pull will handle bits correctly"""
118- wt2 = self.commit_and_branch()
119+ wt2, r1 = self.commit_and_branch()
120
121 os.remove('b1/a')
122 os.remove('b1/b')
123- self.wt.commit('removed', rev_id='r2')
124+ r2 = self.wt.commit('removed')
125
126 # now wt2 can pull and the files should be removed
127
128 # Make sure pull will delete the files
129 wt2.pull(self.wt.branch)
130- self.assertEqual(['r2'], wt2.get_parent_ids())
131- self.assertEqual('r2', wt2.branch.last_revision())
132+ self.assertEqual([r2], wt2.get_parent_ids())
133+ self.assertEqual(r2, wt2.branch.last_revision())
134 self.check_empty(wt2)
135
136 # Now restore the files on the first branch and commit
137 # so that the second branch can pull the changes
138 # and make sure that the executable bit has been copied
139- rev_tree = self.wt.branch.repository.revision_tree('r1')
140+ rev_tree = self.wt.branch.repository.revision_tree(r1)
141 self.wt.revert(old_tree=rev_tree, backups=False)
142- self.wt.commit('resurrected', rev_id='r3')
143+ r3 = self.wt.commit('resurrected')
144
145 self.check_exist(self.wt)
146
147 wt2.pull(self.wt.branch)
148- self.assertEqual(['r3'], wt2.get_parent_ids())
149- self.assertEqual('r3', wt2.branch.last_revision())
150+ self.assertEqual([r3], wt2.get_parent_ids())
151+ self.assertEqual(r3, wt2.branch.last_revision())
152 self.check_exist(wt2)
153
154 def test_08_no_op_revert(self):
155@@ -170,8 +170,8 @@
156
157 The bits shouldn't swap.
158 """
159- self.wt.commit('adding a,b', rev_id='r1')
160- rev_tree = self.wt.branch.repository.revision_tree('r1')
161+ r1 = self.wt.commit('adding a,b')
162+ rev_tree = self.wt.branch.repository.revision_tree(r1)
163 self.wt.revert(old_tree=rev_tree, backups=False)
164 self.check_exist(self.wt)
165

Subscribers

People subscribed via source and target branches