5036.2.9
by Vincent Ladeuil
Keep only the relevant tests. |
1 |
# Copyright (C) 2005, 2006, 2007, 2009, 2010 Canonical Ltd
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
2 |
#
|
743
by Martin Pool
- new simple versioning test cases |
3 |
# This program is free software; you can redistribute it and/or modify
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
7 |
#
|
743
by Martin Pool
- new simple versioning test cases |
8 |
# This program is distributed in the hope that it will be useful,
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
1887.1.1
by Adeodato Simó
Do not separate paragraphs in the copyright statement with blank lines, |
12 |
#
|
743
by Martin Pool
- new simple versioning test cases |
13 |
# You should have received a copy of the GNU General Public License
|
14 |
# along with this program; if not, write to the Free Software
|
|
4183.7.1
by Sabin Iacob
update FSF mailing address |
15 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
743
by Martin Pool
- new simple versioning test cases |
16 |
|
17 |
||
18 |
"""Tests of simple versioning operations"""
|
|
19 |
||
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
20 |
# TODO: test trying to commit within a directory that is not yet added
|
21 |
||
22 |
||
23 |
import os |
|
1125
by Martin Pool
- test code exercises a successful check and null upgrade of a branch |
24 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
25 |
from bzrlib.branch import Branch |
5036.2.3
by Parth Malwankar
intermediate checkin. Repo test case passing. |
26 |
from bzrlib.osutils import pathjoin |
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
27 |
from bzrlib.tests import TestCaseInTempDir, TestCaseWithTransport |
1185.33.12
by Martin Pool
Remove some direct calls to logging, and some dead code |
28 |
from bzrlib.trace import mutter |
1534.4.36
by Robert Collins
Finish deprecating Branch.working_tree() |
29 |
from bzrlib.workingtree import WorkingTree |
1125
by Martin Pool
- test code exercises a successful check and null upgrade of a branch |
30 |
|
743
by Martin Pool
- new simple versioning test cases |
31 |
|
5036.2.3
by Parth Malwankar
intermediate checkin. Repo test case passing. |
32 |
class TestMkdir(TestCaseWithTransport): |
33 |
||
5036.2.9
by Vincent Ladeuil
Keep only the relevant tests. |
34 |
def test_mkdir_fails_cleanly(self): |
35 |
"""'mkdir' fails cleanly when no working tree is available.
|
|
5243.1.2
by Martin
Point launchpad links in comments at production server rather than edge |
36 |
https://bugs.launchpad.net/bzr/+bug/138600
|
5036.2.9
by Vincent Ladeuil
Keep only the relevant tests. |
37 |
"""
|
38 |
# Since there is a safety working tree above us, we create a bare repo
|
|
39 |
# here locally.
|
|
40 |
shared_repo = self.make_repository('.') |
|
41 |
self.run_bzr(['mkdir', 'abc'], retcode=3) |
|
5784.1.3
by Martin Pool
Switch away from using failUnlessExists and failIfExists |
42 |
self.assertPathDoesNotExist('abc') |
5036.2.7
by Parth Malwankar
fixed mkdir and added test case for unversioned dir within branch |
43 |
|
5036.2.3
by Parth Malwankar
intermediate checkin. Repo test case passing. |
44 |
|
1141
by Martin Pool
- rename FunctionalTest to TestCaseInTempDir |
45 |
class TestVersioning(TestCaseInTempDir): |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
46 |
|
47 |
def test_mkdir(self): |
|
744
by Martin Pool
- show nicer descriptions while running tests |
48 |
"""Basic 'bzr mkdir' operation"""
|
743
by Martin Pool
- new simple versioning test cases |
49 |
|
1478
by Robert Collins
convert versioning tests to use self.run_bzr, making the test suite quieter |
50 |
self.run_bzr('init') |
5036.2.8
by Parth Malwankar
updated based on review comments. |
51 |
self.run_bzr(['mkdir', 'foo']) |
743
by Martin Pool
- new simple versioning test cases |
52 |
self.assert_(os.path.isdir('foo')) |
53 |
||
5036.2.8
by Parth Malwankar
updated based on review comments. |
54 |
self.run_bzr(['mkdir', 'foo'], retcode=3) |
749
by Martin Pool
- More tests for bzr mkdir |
55 |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
56 |
wt = WorkingTree.open('.') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
57 |
|
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
58 |
delta = wt.changes_from(wt.basis_tree()) |
749
by Martin Pool
- More tests for bzr mkdir |
59 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
60 |
self.log('delta.added = %r' % delta.added) |
61 |
||
749
by Martin Pool
- More tests for bzr mkdir |
62 |
self.assertEquals(len(delta.added), 1) |
63 |
self.assertEquals(delta.added[0][0], 'foo') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
64 |
self.assertFalse(delta.modified) |
749
by Martin Pool
- More tests for bzr mkdir |
65 |
|
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
66 |
def test_mkdir_in_subdir(self): |
67 |
"""'bzr mkdir' operation in subdirectory"""
|
|
68 |
||
69 |
self.run_bzr('init') |
|
5036.2.8
by Parth Malwankar
updated based on review comments. |
70 |
self.run_bzr(['mkdir', 'dir']) |
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
71 |
self.assert_(os.path.isdir('dir')) |
72 |
||
73 |
os.chdir('dir') |
|
74 |
self.log('Run mkdir in subdir') |
|
5036.2.8
by Parth Malwankar
updated based on review comments. |
75 |
self.run_bzr(['mkdir', 'subdir']) |
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
76 |
self.assert_(os.path.isdir('subdir')) |
77 |
os.chdir('..') |
|
78 |
||
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
79 |
wt = WorkingTree.open('.') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
80 |
|
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
81 |
delta = wt.changes_from(wt.basis_tree()) |
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
82 |
|
83 |
self.log('delta.added = %r' % delta.added) |
|
84 |
||
85 |
self.assertEquals(len(delta.added), 2) |
|
86 |
self.assertEquals(delta.added[0][0], 'dir') |
|
1185.31.32
by John Arbash Meinel
Updated the bzr sourcecode to use bzrlib.osutils.pathjoin rather than os.path.join to enforce internal use of / instead of \ |
87 |
self.assertEquals(delta.added[1][0], pathjoin('dir','subdir')) |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
88 |
self.assertFalse(delta.modified) |
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
89 |
|
1185.31.8
by John Arbash Meinel
Modified mkdir functionality, to handle multiple nested trees. |
90 |
def test_mkdir_w_nested_trees(self): |
91 |
"""'bzr mkdir' with nested trees"""
|
|
92 |
||
93 |
self.run_bzr('init') |
|
94 |
os.mkdir('a') |
|
95 |
os.chdir('a') |
|
96 |
self.run_bzr('init') |
|
97 |
os.mkdir('b') |
|
98 |
os.chdir('b') |
|
99 |
self.run_bzr('init') |
|
100 |
os.chdir('../..') |
|
101 |
||
5036.2.8
by Parth Malwankar
updated based on review comments. |
102 |
self.run_bzr(['mkdir', 'dir', 'a/dir', 'a/b/dir']) |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
103 |
self.assertTrue(os.path.isdir('dir')) |
104 |
self.assertTrue(os.path.isdir('a/dir')) |
|
105 |
self.assertTrue(os.path.isdir('a/b/dir')) |
|
1185.31.8
by John Arbash Meinel
Modified mkdir functionality, to handle multiple nested trees. |
106 |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
107 |
wt = WorkingTree.open('.') |
108 |
wt_a = WorkingTree.open('a') |
|
109 |
wt_b = WorkingTree.open('a/b') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
110 |
|
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
111 |
delta = wt.changes_from(wt.basis_tree()) |
112 |
self.assertEquals(len(delta.added), 1) |
|
113 |
self.assertEquals(delta.added[0][0], 'dir') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
114 |
self.assertFalse(delta.modified) |
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
115 |
|
116 |
delta = wt_a.changes_from(wt_a.basis_tree()) |
|
117 |
self.assertEquals(len(delta.added), 1) |
|
118 |
self.assertEquals(delta.added[0][0], 'dir') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
119 |
self.assertFalse(delta.modified) |
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
120 |
|
121 |
delta = wt_b.changes_from(wt_b.basis_tree()) |
|
1185.31.8
by John Arbash Meinel
Modified mkdir functionality, to handle multiple nested trees. |
122 |
self.assertEquals(len(delta.added), 1) |
123 |
self.assertEquals(delta.added[0][0], 'dir') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
124 |
self.assertFalse(delta.modified) |
1185.31.8
by John Arbash Meinel
Modified mkdir functionality, to handle multiple nested trees. |
125 |
|
1380
by Martin Pool
- upgrade can no longer be done in current version branches |
126 |
def check_branch(self): |
1125
by Martin Pool
- test code exercises a successful check and null upgrade of a branch |
127 |
"""After all the above changes, run the check and upgrade commands.
|
128 |
||
129 |
The upgrade should be a no-op."""
|
|
1185.33.66
by Martin Pool
[patch] use unicode literals for all hardcoded paths (Alexander Belchenko) |
130 |
b = Branch.open(u'.') |
1185.33.12
by Martin Pool
Remove some direct calls to logging, and some dead code |
131 |
mutter('branch has %d revisions', b.revno()) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
132 |
|
1185.33.12
by Martin Pool
Remove some direct calls to logging, and some dead code |
133 |
mutter('check branch...') |
1125
by Martin Pool
- test code exercises a successful check and null upgrade of a branch |
134 |
from bzrlib.check import check |
1450
by Robert Collins
hah, missed tests in check changes |
135 |
check(b, False) |
1506
by Robert Collins
Merge Johns current integration work. |
136 |
|
137 |
||
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
138 |
class SubdirCommit(TestCaseWithTransport): |
1102
by Martin Pool
- merge test refactoring from robertc |
139 |
|
140 |
def test_subdir_commit(self): |
|
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
141 |
"""Test committing a subdirectory, and committing a directory."""
|
142 |
tree = self.make_branch_and_tree('.') |
|
143 |
b = tree.branch |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
144 |
self.build_tree(['a/', 'b/']) |
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
145 |
def set_contents(contents): |
146 |
self.build_tree_contents([ |
|
147 |
('a/one', contents), |
|
148 |
('b/two', contents), |
|
149 |
('top', contents), |
|
150 |
])
|
|
151 |
set_contents('old contents') |
|
152 |
tree.smart_add(['.']) |
|
153 |
tree.commit('first revision') |
|
154 |
set_contents('new contents') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
155 |
|
1185.33.12
by Martin Pool
Remove some direct calls to logging, and some dead code |
156 |
mutter('start selective subdir commit') |
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
157 |
self.run_bzr(['commit', 'a', '-m', 'commit a only']) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
158 |
|
1185.67.2
by Aaron Bentley
Renamed Branch.storage to Branch.repository |
159 |
new = b.repository.revision_tree(b.get_rev_id(2)) |
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
160 |
new.lock_read() |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
161 |
|
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
162 |
self.assertEqual(new.get_file_by_path('b/two').read(), 'old contents') |
163 |
self.assertEqual(new.get_file_by_path('top').read(), 'old contents') |
|
164 |
self.assertEqual(new.get_file_by_path('a/one').read(), 'new contents') |
|
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
165 |
new.unlock() |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
166 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
167 |
os.chdir('a') |
168 |
# commit from here should do nothing
|
|
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
169 |
self.run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged']) |
1185.67.2
by Aaron Bentley
Renamed Branch.storage to Branch.repository |
170 |
v3 = b.repository.revision_tree(b.get_rev_id(3)) |
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
171 |
v3.lock_read() |
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
172 |
self.assertEqual(v3.get_file_by_path('b/two').read(), 'old contents') |
173 |
self.assertEqual(v3.get_file_by_path('top').read(), 'old contents') |
|
174 |
self.assertEqual(v3.get_file_by_path('a/one').read(), 'new contents') |
|
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
175 |
v3.unlock() |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
176 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
177 |
# commit in subdirectory commits whole tree
|
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
178 |
self.run_bzr(['commit', '-m', 'commit whole tree from subdir']) |
1185.67.2
by Aaron Bentley
Renamed Branch.storage to Branch.repository |
179 |
v4 = b.repository.revision_tree(b.get_rev_id(4)) |
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
180 |
v4.lock_read() |
4570.4.3
by Robert Collins
Fix a couple of small bugs in the patch - use specific files with record_iter_changs, and the CLI shouldn't generate a filter of [] for commit. |
181 |
self.assertEqual(v4.get_file_by_path('b/two').read(), 'new contents') |
182 |
self.assertEqual(v4.get_file_by_path('top').read(), 'new contents') |
|
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
183 |
v4.unlock() |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
184 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
185 |
# TODO: factor out some kind of assert_tree_state() method
|