~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/blackbox.py

  • Committer: Aaron Bentley
  • Date: 2007-07-26 15:52:55 UTC
  • Revision ID: abentley@panoramicfeedback.com-20070726155255-cawzo84zpzoulzbr
Allow importing directly from a URL

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import os
 
1
from bzrlib.tests.blackbox import ExternalBase
 
2
from unittest import makeSuite
2
3
import os.path
3
 
from unittest import makeSuite
4
 
 
5
 
from bzrlib import branch, osutils, workingtree
6
 
from bzrlib.config import LocationConfig
7
 
from bzrlib.transport import get_transport
8
 
from bzrlib.tests import TestCaseWithTransport, HardlinkFeature
9
 
 
10
 
 
11
 
class TestBzrTools(TestCaseWithTransport):
 
4
class TestBzrTools(ExternalBase):
12
5
    @staticmethod
13
6
    def touch(filename):
14
7
        file(filename, 'wb').write('')
15
8
 
 
9
    def test_clean_tree(self):
 
10
        self.run_bzr('init')
 
11
        self.run_bzr('ignore *~')
 
12
        self.run_bzr('ignore *.pyc')
 
13
        self.touch('name')
 
14
        self.touch('name~')
 
15
        assert os.path.lexists('name~')
 
16
        self.touch('name.pyc')
 
17
        self.run_bzr('clean-tree')
 
18
        assert os.path.lexists('name~')
 
19
        assert not os.path.lexists('name')
 
20
        self.touch('name')
 
21
        self.run_bzr('clean-tree --detritus')
 
22
        assert os.path.lexists('name')
 
23
        assert not os.path.lexists('name~')
 
24
        assert os.path.lexists('name.pyc')
 
25
        self.run_bzr('clean-tree --ignored')
 
26
        assert os.path.lexists('name')
 
27
        assert not os.path.lexists('name.pyc')
 
28
        self.run_bzr('clean-tree --unknown')
 
29
        assert not os.path.lexists('name')
 
30
        self.touch('name')
 
31
        self.touch('name~')
 
32
        self.touch('name.pyc')
 
33
        self.run_bzr('clean-tree --unknown --ignored')
 
34
        assert not os.path.lexists('name')
 
35
        assert not os.path.lexists('name~')
 
36
        assert not os.path.lexists('name.pyc')
 
37
 
16
38
    def test_shelve(self):
17
39
        self.run_bzr('init')
18
40
        self.run_bzr('commit -m uc --unchanged')
19
 
        self.run_bzr('shelve1 -r 1 -m foo --all', retcode=3)
 
41
        self.run_bzr('shelve -r 1 -m foo --all', retcode=3)
20
42
        file('foo', 'wb').write('foo')
21
43
        self.run_bzr('add foo')
22
44
        self.run_bzr('commit -m foo')
23
 
        self.run_bzr('shelve1 -r 1 -m foo --all', retcode=0)
 
45
        self.run_bzr('shelve -r 1 -m foo --all', retcode=0)
24
46
 
25
47
    def test_fetch_ghosts(self):
26
48
        self.run_bzr('init')
69
91
        self.assertIs(False, os.path.exists('checkout'))
70
92
        self.assertIs(True, os.path.exists('source'))
71
93
 
72
 
    def test_zap_modified(self):
73
 
        tree = self.make_branch_and_tree('source')
74
 
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
75
 
        self.build_tree(['checkout/file'])
76
 
        checkout.add('file')
77
 
        self.run_bzr_error(('This checkout has uncommitted changes',),
78
 
                           'zap checkout')
79
 
        self.failUnlessExists('checkout')
80
 
        self.run_bzr('zap checkout --force')
81
 
        self.failIfExists('checkout')
82
 
        self.failUnlessExists('source')
83
 
 
84
94
    def test_zap_branch(self):
85
95
        self.run_bzr('init source')
86
96
        self.run_bzr('checkout --lightweight source checkout')
105
115
        self.assertIs(True, 'source/subsource' in lines)
106
116
        self.assertIs(True, 'checkout/subcheckout' in lines)
107
117
        self.assertIs(True, 'checkout' not in lines)
 
118
        self.assertIs(True, 'checkout/.bzr/subcheckout' not in lines)
108
119
 
109
120
    def test_import_upstream(self):
110
121
        self.run_bzr('init source')
137
148
        self.run_bzr('import source-0.1 import5')
138
149
        self.failUnlessExists('import5/src/myfile')
139
150
 
140
 
    def test_cbranch(self):
141
 
        source = self.make_branch_and_tree('source')
142
 
        config = LocationConfig(osutils.abspath('target'))
143
 
        config.set_user_option('cbranch_target', 'target_branch')
144
 
        self.run_bzr('cbranch source target')
145
 
        checkout = workingtree.WorkingTree.open('target')
146
 
        self.assertEqual(checkout.branch.base,
147
 
                         get_transport('target').base)
148
 
        self.assertEqual(checkout.branch.get_master_branch().base,
149
 
                         get_transport('target_branch').base)
150
 
        self.assertEqual(checkout.branch.get_master_branch().get_parent(),
151
 
                         get_transport('source').base)
152
 
 
153
 
    def test_cbranch_hardlink(self):
154
 
        self.requireFeature(HardlinkFeature)
155
 
        # Later formats don't support hardlinks.  Boo!
156
 
        source = self.make_branch_and_tree('source', format='1.9')
157
 
        self.build_tree(['source/file'])
158
 
        source.add('file')
159
 
        source.commit('added file')
160
 
        config = LocationConfig(osutils.abspath('target'))
161
 
        config.set_user_option('cbranch_target', 'target_branch')
162
 
        self.run_bzr('cbranch source target --lightweight')
163
 
        checkout = workingtree.WorkingTree.open('target')
164
 
        self.assertNotEqual(os.lstat(checkout.abspath('file')).st_ino,
165
 
                            os.lstat(source.abspath('file')).st_ino)
166
 
        config = LocationConfig(osutils.abspath('target2'))
167
 
        config.set_user_option('cbranch_target', 'target_branch2')
168
 
        self.run_bzr('cbranch source target2 --lightweight --hardlink')
169
 
        checkout2 = workingtree.WorkingTree.open('target2')
170
 
        self.assertEqual(os.lstat(checkout2.abspath('file')).st_ino,
171
 
                         os.lstat(source.abspath('file')).st_ino)
172
 
 
173
 
    def test_create_mirror(self):
174
 
        source = self.make_branch_and_tree('source')
175
 
        source.commit('message')
176
 
        self.run_bzr('create-mirror source target')
177
 
        target = branch.Branch.open('target')
178
 
        self.assertEqual(source.last_revision(), target.last_revision())
179
 
        self.assertEqual(source.branch.base, target.get_public_branch())
180
 
 
181
 
 
182
151
def test_suite():
183
152
    return makeSuite(TestBzrTools)