6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
1 |
# Copyright (C) 2005, 2006, 2007, 2009-2012 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 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
44 |
def test_mkdir(self): |
744
by Martin Pool
- show nicer descriptions while running tests |
45 |
"""Basic 'bzr mkdir' operation"""
|
743
by Martin Pool
- new simple versioning test cases |
46 |
|
5071.1.6
by Martin von Gagern
Cleaned up selftest code in response to suggestions by Martin Packman. |
47 |
self.make_branch_and_tree('.') |
5036.2.8
by Parth Malwankar
updated based on review comments. |
48 |
self.run_bzr(['mkdir', 'foo']) |
743
by Martin Pool
- new simple versioning test cases |
49 |
self.assert_(os.path.isdir('foo')) |
50 |
||
5036.2.8
by Parth Malwankar
updated based on review comments. |
51 |
self.run_bzr(['mkdir', 'foo'], retcode=3) |
749
by Martin Pool
- More tests for bzr mkdir |
52 |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
53 |
wt = WorkingTree.open('.') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
54 |
|
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
55 |
delta = wt.changes_from(wt.basis_tree()) |
749
by Martin Pool
- More tests for bzr mkdir |
56 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
57 |
self.log('delta.added = %r' % delta.added) |
58 |
||
749
by Martin Pool
- More tests for bzr mkdir |
59 |
self.assertEquals(len(delta.added), 1) |
60 |
self.assertEquals(delta.added[0][0], 'foo') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
61 |
self.assertFalse(delta.modified) |
749
by Martin Pool
- More tests for bzr mkdir |
62 |
|
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
63 |
def test_mkdir_in_subdir(self): |
64 |
"""'bzr mkdir' operation in subdirectory"""
|
|
65 |
||
5071.1.6
by Martin von Gagern
Cleaned up selftest code in response to suggestions by Martin Packman. |
66 |
self.make_branch_and_tree('.') |
5036.2.8
by Parth Malwankar
updated based on review comments. |
67 |
self.run_bzr(['mkdir', 'dir']) |
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
68 |
self.assert_(os.path.isdir('dir')) |
69 |
||
70 |
self.log('Run mkdir in subdir') |
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
71 |
self.run_bzr(['mkdir', 'subdir'], working_dir='dir') |
72 |
self.assert_(os.path.isdir('dir/subdir')) |
|
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
73 |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
74 |
wt = WorkingTree.open('.') |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
75 |
|
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
76 |
delta = wt.changes_from(wt.basis_tree()) |
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
77 |
|
78 |
self.log('delta.added = %r' % delta.added) |
|
79 |
||
80 |
self.assertEquals(len(delta.added), 2) |
|
81 |
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 \ |
82 |
self.assertEquals(delta.added[1][0], pathjoin('dir','subdir')) |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
83 |
self.assertFalse(delta.modified) |
1185.31.7
by John Arbash Meinel
Applying Alexander Belchenko's patch to handle multiple mkdir calls |
84 |
|
1185.31.8
by John Arbash Meinel
Modified mkdir functionality, to handle multiple nested trees. |
85 |
def test_mkdir_w_nested_trees(self): |
86 |
"""'bzr mkdir' with nested trees"""
|
|
87 |
||
5071.1.6
by Martin von Gagern
Cleaned up selftest code in response to suggestions by Martin Packman. |
88 |
self.make_branch_and_tree('.') |
89 |
self.make_branch_and_tree('a') |
|
90 |
self.make_branch_and_tree('a/b') |
|
1185.31.8
by John Arbash Meinel
Modified mkdir functionality, to handle multiple nested trees. |
91 |
|
5036.2.8
by Parth Malwankar
updated based on review comments. |
92 |
self.run_bzr(['mkdir', 'dir', 'a/dir', 'a/b/dir']) |
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
93 |
self.assertTrue(os.path.isdir('dir')) |
94 |
self.assertTrue(os.path.isdir('a/dir')) |
|
95 |
self.assertTrue(os.path.isdir('a/b/dir')) |
|
1185.31.8
by John Arbash Meinel
Modified mkdir functionality, to handle multiple nested trees. |
96 |
|
1508.1.19
by Robert Collins
Give format3 working trees their own last-revision marker. |
97 |
wt = WorkingTree.open('.') |
98 |
wt_a = WorkingTree.open('a') |
|
99 |
wt_b = WorkingTree.open('a/b') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
100 |
|
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
101 |
delta = wt.changes_from(wt.basis_tree()) |
102 |
self.assertEquals(len(delta.added), 1) |
|
103 |
self.assertEquals(delta.added[0][0], 'dir') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
104 |
self.assertFalse(delta.modified) |
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
105 |
|
106 |
delta = wt_a.changes_from(wt_a.basis_tree()) |
|
107 |
self.assertEquals(len(delta.added), 1) |
|
108 |
self.assertEquals(delta.added[0][0], 'dir') |
|
5784.1.1
by Martin Pool
Stop using failIf, failUnless, etc |
109 |
self.assertFalse(delta.modified) |
1852.10.3
by Robert Collins
Remove all uses of compare_trees and replace with Tree.changes_from throughout bzrlib. |
110 |
|
111 |
delta = wt_b.changes_from(wt_b.basis_tree()) |
|
1185.31.8
by John Arbash Meinel
Modified mkdir functionality, to handle multiple nested trees. |
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) |
1185.31.8
by John Arbash Meinel
Modified mkdir functionality, to handle multiple nested trees. |
115 |
|
5071.1.1
by Martin von Gagern
Added blackbox test expectig "bzr mkdir --quiet foo" to not print anything. |
116 |
def test_mkdir_quiet(self): |
117 |
"""'bzr mkdir --quiet' should not print a status message"""
|
|
118 |
||
5071.1.6
by Martin von Gagern
Cleaned up selftest code in response to suggestions by Martin Packman. |
119 |
self.make_branch_and_tree('.') |
5071.1.1
by Martin von Gagern
Added blackbox test expectig "bzr mkdir --quiet foo" to not print anything. |
120 |
out, err = self.run_bzr(['mkdir', '--quiet', 'foo']) |
121 |
self.assertEquals('', err) |
|
122 |
self.assertEquals('', out) |
|
123 |
||
1506
by Robert Collins
Merge Johns current integration work. |
124 |
|
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. |
125 |
class SubdirCommit(TestCaseWithTransport): |
1102
by Martin Pool
- merge test refactoring from robertc |
126 |
|
127 |
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. |
128 |
"""Test committing a subdirectory, and committing a directory."""
|
129 |
tree = self.make_branch_and_tree('.') |
|
130 |
b = tree.branch |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
131 |
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. |
132 |
def set_contents(contents): |
133 |
self.build_tree_contents([ |
|
134 |
('a/one', contents), |
|
135 |
('b/two', contents), |
|
136 |
('top', contents), |
|
137 |
])
|
|
138 |
set_contents('old contents') |
|
139 |
tree.smart_add(['.']) |
|
140 |
tree.commit('first revision') |
|
141 |
set_contents('new contents') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
142 |
|
1185.33.12
by Martin Pool
Remove some direct calls to logging, and some dead code |
143 |
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. |
144 |
self.run_bzr(['commit', 'a', '-m', 'commit a only']) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
145 |
|
1185.67.2
by Aaron Bentley
Renamed Branch.storage to Branch.repository |
146 |
new = b.repository.revision_tree(b.get_rev_id(2)) |
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
147 |
new.lock_read() |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
148 |
|
6290.1.1
by Jelmer Vernooij
Remove broken Tree.get_file_by_path. |
149 |
def get_text_by_path(tree, path): |
150 |
return tree.get_file_text(tree.path2id(path), path) |
|
151 |
||
6290.1.3
by Jelmer Vernooij
Fix test. |
152 |
self.assertEqual(get_text_by_path(new, 'b/two'), 'old contents') |
153 |
self.assertEqual(get_text_by_path(new, 'top'), 'old contents') |
|
154 |
self.assertEqual(get_text_by_path(new, 'a/one'), 'new contents') |
|
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
155 |
new.unlock() |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
156 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
157 |
# commit from here should do nothing
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
158 |
self.run_bzr(['commit', '.', '-m', 'commit subdir only', '--unchanged'], |
159 |
working_dir='a') |
|
1185.67.2
by Aaron Bentley
Renamed Branch.storage to Branch.repository |
160 |
v3 = b.repository.revision_tree(b.get_rev_id(3)) |
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
161 |
v3.lock_read() |
6290.1.1
by Jelmer Vernooij
Remove broken Tree.get_file_by_path. |
162 |
self.assertEqual(get_text_by_path(v3, 'b/two'), 'old contents') |
163 |
self.assertEqual(get_text_by_path(v3, 'top'), 'old contents') |
|
164 |
self.assertEqual(get_text_by_path(v3, 'a/one'), 'new contents') |
|
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
165 |
v3.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 |
# commit in subdirectory commits whole tree
|
6423.1.1
by Vincent Ladeuil
Cleanup old blackbox tests and then some. Remove os.chdir() calls, caught a few bugs, make sure we don't leave file handles opened. |
168 |
self.run_bzr(['commit', '-m', 'commit whole tree from subdir'], |
169 |
working_dir='a') |
|
1185.67.2
by Aaron Bentley
Renamed Branch.storage to Branch.repository |
170 |
v4 = b.repository.revision_tree(b.get_rev_id(4)) |
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
171 |
v4.lock_read() |
6290.1.1
by Jelmer Vernooij
Remove broken Tree.get_file_by_path. |
172 |
self.assertEqual(get_text_by_path(v4, 'b/two'), 'new contents') |
173 |
self.assertEqual(get_text_by_path(v4, 'top'), 'new contents') |
|
3010.1.16
by Robert Collins
Lock correctness in test_versioning |
174 |
v4.unlock() |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
175 |
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
176 |
# TODO: factor out some kind of assert_tree_state() method
|