1
# Copyright (C) 2008, 2009, 2010, 2016 Canonical Ltd
2
# -*- coding: utf-8 -*-
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
"""Black-box tests for 'brz modified', which shows modified files."""
23
from breezy.branch import Branch
24
from breezy.tests import TestCaseWithTransport
27
class TestModified(TestCaseWithTransport):
29
def test_modified(self):
30
"""Test that 'modified' command reports modified files"""
31
self._test_modified('a', 'a')
33
def test_modified_with_spaces(self):
34
"""Test that 'modified' command reports modified files with spaces in their names quoted"""
35
self._test_modified('a filename with spaces',
36
'"a filename with spaces"')
38
def _test_modified(self, name, output):
40
def check_modified(expected, null=False):
44
out, err = self.run_bzr(command)
45
self.assertEqual(out, expected)
46
self.assertEqual(err, '')
48
# in empty directory, nothing modified
49
tree = self.make_branch_and_tree('.')
52
# with unknown file, still nothing modified
53
self.build_tree_contents(
54
[(name, b'contents of %s\n' % (name.encode('utf-8')))])
57
# after add, not modified
61
# after commit, not modified
62
tree.commit(message='add %s' % output)
66
self.build_tree_contents([(name, b'changed\n')])
67
check_modified(output + '\n')
69
# check null seps - use the unquoted raw name here
70
check_modified(name + '\0', null=True)
72
# now commit the file and it's no longer modified
73
tree.commit(message='modified %s' % (name))
76
def test_modified_directory(self):
77
"""Test --directory option"""
78
tree = self.make_branch_and_tree('a')
79
self.build_tree(['a/README'])
82
self.build_tree_contents([('a/README', b'changed\n')])
83
out, err = self.run_bzr(['modified', '--directory=a'])
84
self.assertEqual('README\n', out)