1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
1 |
# Copyright (C) 2005, 2006 by Canonical Ltd
|
2 |
#
|
|
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.
|
|
7 |
#
|
|
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.
|
|
12 |
#
|
|
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
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
#
|
|
17 |
||
18 |
"""Tests of the 'bzr add' command."""
|
|
19 |
||
20 |
import os |
|
21 |
||
1836.1.16
by John Arbash Meinel
Cleanup some tests which don't expect .bazaar/ to show up. Some still fail. |
22 |
from bzrlib import ignores |
23 |
||
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
24 |
from bzrlib.tests.blackbox import ExternalBase |
25 |
||
26 |
||
27 |
class TestAdd(ExternalBase): |
|
28 |
||
29 |
def test_add_reports(self): |
|
30 |
"""add command prints the names of added files."""
|
|
1836.1.31
by John Arbash Meinel
Make set_user_ignores a private function, and update the doc string to recommend it isn't used. |
31 |
ignores._set_user_ignores(['./.bazaar']) |
1836.1.16
by John Arbash Meinel
Cleanup some tests which don't expect .bazaar/ to show up. Some still fail. |
32 |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
33 |
self.runbzr('init') |
34 |
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt', 'CVS']) |
|
1765.1.1
by Robert Collins
Remove the default ignores list from bzr, lowering the minimum overhead in bzr add. |
35 |
self.build_tree_contents([('.bzrignore', 'CVS\n')]) |
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
36 |
out = self.run_bzr_captured(['add'], retcode=0)[0] |
37 |
# the ordering is not defined at the moment
|
|
38 |
results = sorted(out.rstrip('\n').split('\n')) |
|
39 |
self.assertEquals(['If you wish to add some of these files, please'\ |
|
40 |
' add them by name.', |
|
1765.1.1
by Robert Collins
Remove the default ignores list from bzr, lowering the minimum overhead in bzr add. |
41 |
'added .bzrignore', |
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
42 |
'added dir', |
43 |
'added dir/sub.txt', |
|
44 |
'added top.txt', |
|
1836.1.16
by John Arbash Meinel
Cleanup some tests which don't expect .bazaar/ to show up. Some still fail. |
45 |
'ignored 2 file(s).'], |
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
46 |
results) |
47 |
out = self.run_bzr_captured(['add', '-v'], retcode=0)[0] |
|
48 |
results = sorted(out.rstrip('\n').split('\n')) |
|
49 |
self.assertEquals(['If you wish to add some of these files, please'\ |
|
50 |
' add them by name.', |
|
1836.1.18
by John Arbash Meinel
Cleaned up the last failing tests. All tests pass again. |
51 |
'ignored .bazaar matching "./.bazaar"', |
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
52 |
'ignored CVS matching "CVS"'], |
53 |
results) |
|
54 |
||
55 |
def test_add_quiet_is(self): |
|
56 |
"""add -q does not print the names of added files."""
|
|
57 |
self.runbzr('init') |
|
58 |
self.build_tree(['top.txt', 'dir/', 'dir/sub.txt']) |
|
59 |
out = self.run_bzr_captured(['add', '-q'], retcode=0)[0] |
|
60 |
# the ordering is not defined at the moment
|
|
61 |
results = sorted(out.rstrip('\n').split('\n')) |
|
62 |
self.assertEquals([''], results) |
|
63 |
||
64 |
def test_add_in_unversioned(self): |
|
65 |
"""Try to add a file in an unversioned directory.
|
|
66 |
||
67 |
"bzr add" should add the parent(s) as necessary.
|
|
68 |
"""
|
|
1836.1.31
by John Arbash Meinel
Make set_user_ignores a private function, and update the doc string to recommend it isn't used. |
69 |
ignores._set_user_ignores(['./.bazaar']) |
1836.1.16
by John Arbash Meinel
Cleanup some tests which don't expect .bazaar/ to show up. Some still fail. |
70 |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
71 |
self.runbzr('init') |
72 |
self.build_tree(['inertiatic/', 'inertiatic/esp']) |
|
73 |
self.assertEquals(self.capture('unknowns'), 'inertiatic\n') |
|
74 |
self.run_bzr('add', 'inertiatic/esp') |
|
75 |
self.assertEquals(self.capture('unknowns'), '') |
|
76 |
||
77 |
# Multiple unversioned parents
|
|
78 |
self.build_tree(['veil/', 'veil/cerpin/', 'veil/cerpin/taxt']) |
|
79 |
self.assertEquals(self.capture('unknowns'), 'veil\n') |
|
80 |
self.run_bzr('add', 'veil/cerpin/taxt') |
|
81 |
self.assertEquals(self.capture('unknowns'), '') |
|
82 |
||
83 |
# Check whacky paths work
|
|
84 |
self.build_tree(['cicatriz/', 'cicatriz/esp']) |
|
85 |
self.assertEquals(self.capture('unknowns'), 'cicatriz\n') |
|
86 |
self.run_bzr('add', 'inertiatic/../cicatriz/esp') |
|
87 |
self.assertEquals(self.capture('unknowns'), '') |
|
88 |
||
89 |
def test_add_in_versioned(self): |
|
90 |
"""Try to add a file in a versioned directory.
|
|
91 |
||
92 |
"bzr add" should do this happily.
|
|
93 |
"""
|
|
1836.1.31
by John Arbash Meinel
Make set_user_ignores a private function, and update the doc string to recommend it isn't used. |
94 |
ignores._set_user_ignores(['./.bazaar']) |
1836.1.16
by John Arbash Meinel
Cleanup some tests which don't expect .bazaar/ to show up. Some still fail. |
95 |
|
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
96 |
self.runbzr('init') |
97 |
self.build_tree(['inertiatic/', 'inertiatic/esp']) |
|
98 |
self.assertEquals(self.capture('unknowns'), 'inertiatic\n') |
|
99 |
self.run_bzr('add', '--no-recurse', 'inertiatic') |
|
100 |
self.assertEquals(self.capture('unknowns'), 'inertiatic/esp\n') |
|
101 |
self.run_bzr('add', 'inertiatic/esp') |
|
102 |
self.assertEquals(self.capture('unknowns'), '') |
|
103 |
||
104 |
def test_subdir_add(self): |
|
105 |
"""Add in subdirectory should add only things from there down"""
|
|
106 |
from bzrlib.workingtree import WorkingTree |
|
1836.1.16
by John Arbash Meinel
Cleanup some tests which don't expect .bazaar/ to show up. Some still fail. |
107 |
|
1836.1.31
by John Arbash Meinel
Make set_user_ignores a private function, and update the doc string to recommend it isn't used. |
108 |
ignores._set_user_ignores(['./.bazaar']) |
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
109 |
eq = self.assertEqual |
1836.1.16
by John Arbash Meinel
Cleanup some tests which don't expect .bazaar/ to show up. Some still fail. |
110 |
ass = self.assertTrue |
1711.1.3
by Robert Collins
Add new test_add file - should have been in last commit. |
111 |
chdir = os.chdir |
112 |
||
113 |
t = self.make_branch_and_tree('.') |
|
114 |
b = t.branch |
|
115 |
self.build_tree(['src/', 'README']) |
|
116 |
||
117 |
eq(sorted(t.unknowns()), |
|
118 |
['README', 'src']) |
|
119 |
||
120 |
self.run_bzr('add', 'src') |
|
121 |
||
122 |
self.build_tree(['src/foo.c']) |
|
123 |
||
124 |
chdir('src') |
|
125 |
self.run_bzr('add') |
|
126 |
||
127 |
self.assertEquals(self.capture('unknowns'), 'README\n') |
|
128 |
eq(len(t.read_working_inventory()), 3) |
|
129 |
||
130 |
chdir('..') |
|
131 |
self.run_bzr('add') |
|
132 |
self.assertEquals(self.capture('unknowns'), '') |
|
133 |
self.run_bzr('check') |
|
1757.2.1
by Robert Collins
Add an explicit test that adding a missing file barfs. |
134 |
|
135 |
def test_add_missing(self): |
|
136 |
"""bzr add foo where foo is missing should error."""
|
|
137 |
self.make_branch_and_tree('.') |
|
138 |
self.run_bzr('add', 'missing-file', retcode=3) |