1
# Copyright (C) 2005, 2006, 2007, 2008 Canonical Ltd
1
# Copyright (C) 2005, 2006, 2007, 2008, 2009 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
171
168
(['src'], 'src'),
173
170
self.assert_(is_inside_or_parent_of_any(dirs, fn))
175
172
for dirs, fn in [(['src'], 'srccontrol'),
176
173
(['srccontrol/foo.c'], 'src'),
177
174
(['src'], 'srccontrol/foo')]:
310
307
self.assertEqual(bar_path, osutils.realpath('./bar'))
311
308
os.symlink('bar', 'foo')
312
309
self.assertEqual(bar_path, osutils.realpath('./foo'))
314
311
# Does not dereference terminal symlinks
315
312
foo_path = osutils.pathjoin(cwd, 'foo')
316
313
self.assertEqual(foo_path, osutils.dereference_path('./foo'))
882
879
self.assertEqual(expected_dirblocks[1:],
883
880
[(dirinfo, [line[0:3] for line in block]) for dirinfo, block in result])
882
def test_walkdirs_os_error(self):
883
# <https://bugs.edge.launchpad.net/bzr/+bug/338653>
884
# Pyrex readdir didn't raise useful messages if it had an error
885
# reading the directory
886
if sys.platform == 'win32':
887
raise tests.TestNotApplicable(
888
"readdir IOError not tested on win32")
889
os.mkdir("test-unreadable")
890
os.chmod("test-unreadable", 0000)
891
# must chmod it back so that it can be removed
892
self.addCleanup(lambda: os.chmod("test-unreadable", 0700))
893
# The error is not raised until the generator is actually evaluated.
894
# (It would be ok if it happened earlier but at the moment it
896
e = self.assertRaises(OSError, list,
897
osutils._walkdirs_utf8("."))
898
self.assertEquals(e.filename, './test-unreadable')
899
self.assertEquals(str(e),
900
"[Errno 13] chdir: Permission denied: './test-unreadable'")
885
902
def test__walkdirs_utf8(self):
1471
1488
self.assertEqual(expected_sha, osutils.sha_file_by_name('foo'))
1475
r'''# Copyright (C) 2005, 2006 Canonical Ltd
1477
# This program is free software; you can redistribute it and/or modify
1478
# it under the terms of the GNU General Public License as published by
1479
# the Free Software Foundation; either version 2 of the License, or
1480
# (at your option) any later version.
1482
# This program is distributed in the hope that it will be useful,
1483
# but WITHOUT ANY WARRANTY; without even the implied warranty of
1484
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1485
# GNU General Public License for more details.
1487
# You should have received a copy of the GNU General Public License
1488
# along with this program; if not, write to the Free Software
1489
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1492
# NOTE: If update these, please also update the help for global-options in
1493
# bzrlib/help_topics/__init__.py
1496
"""Set of flags that enable different debug behaviour.
1498
These are set with eg ``-Dlock`` on the bzr command line.
1502
* auth - show authentication sections used
1503
* error - show stack traces for all top level exceptions
1504
* evil - capture call sites that do expensive or badly-scaling operations.
1505
* fetch - trace history copying between repositories
1506
* graph - trace graph traversal information
1507
* hashcache - log every time a working file is read to determine its hash
1508
* hooks - trace hook execution
1509
* hpss - trace smart protocol requests and responses
1510
* http - trace http connections, requests and responses
1511
* index - trace major index operations
1512
* knit - trace knit operations
1513
* lock - trace when lockdir locks are taken or released
1514
* merge - emit information for debugging merges
1515
* pack - emit information about pack operations
1521
1491
class TestResourceLoading(TestCaseInTempDir):
1523
1493
def test_resource_string(self):
1524
1494
# test resource in bzrlib
1525
1495
text = osutils.resource_string('bzrlib', 'debug.py')
1526
self.assertEquals(_debug_text, text)
1496
self.assertContainsRe(text, "debug_flags = set()")
1527
1497
# test resource under bzrlib
1528
1498
text = osutils.resource_string('bzrlib.ui', 'text.py')
1529
1499
self.assertContainsRe(text, "class TextUIFactory")