/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tests/test_blackbox.py

More test fixes.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
"""Black-box tests for bzr-git."""
18
18
 
 
19
from dulwich.repo import (
 
20
    Repo as GitRepo,
 
21
    )
 
22
 
19
23
import os
20
24
 
 
25
from bzrlib import (
 
26
    version_info as bzrlib_version,
 
27
    )
 
28
from bzrlib.bzrdir import (
 
29
    BzrDir,
 
30
    )
 
31
 
 
32
from bzrlib.tests.blackbox import ExternalBase
21
33
from bzrlib.tests import KnownFailure
22
 
from bzrlib.tests.blackbox import ExternalBase
23
34
 
 
35
from bzrlib.plugins.git.mapping import mapping_registry
24
36
from bzrlib.plugins.git import (
25
37
    tests,
26
38
    )
30
42
 
31
43
    def simple_commit(self):
32
44
        # Create a git repository with a revision.
33
 
        tests.run_git('init')
 
45
        repo = GitRepo.init(self.test_dir)
34
46
        builder = tests.GitBranchBuilder()
35
47
        builder.set_file('a', 'text for a\n', False)
36
 
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
37
 
        builder.finish()
 
48
        r1 = builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
 
49
        return repo, builder.finish()[r1]
 
50
 
 
51
    def test_nick(self):
 
52
        GitRepo.init(self.test_dir)
 
53
        dir = BzrDir.open(self.test_dir)
 
54
        dir.create_branch()
 
55
        output, error = self.run_bzr(['nick'])
 
56
        self.assertEquals("master\n", output)
38
57
 
39
58
    def test_info(self):
40
59
        self.simple_commit()
41
60
        output, error = self.run_bzr(['info'])
42
61
        self.assertEqual(error, '')
43
 
        self.assertTrue("Repository tree (format: git)" in output)
 
62
        self.assertTrue("Standalone tree (format: git)" in output)
44
63
 
45
64
    def test_branch(self):
46
65
        os.mkdir("gitbranch")
47
 
        os.chdir("gitbranch")
48
 
        tests.run_git('init')
 
66
        GitRepo.init(os.path.join(self.test_dir, "gitbranch"))
 
67
        os.chdir('gitbranch')
49
68
        builder = tests.GitBranchBuilder()
50
69
        builder.set_file('a', 'text for a\n', False)
51
70
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
52
71
        builder.finish()
 
72
        os.chdir('..')
53
73
 
54
 
        os.chdir("..")
55
74
        output, error = self.run_bzr(['branch', 'gitbranch', 'bzrbranch'])
56
75
        self.assertEqual(error, 'Branched 1 revision(s).\n')
 
76
 
 
77
    def test_checkout(self):
 
78
        os.mkdir("gitbranch")
 
79
        GitRepo.init(os.path.join(self.test_dir, "gitbranch"))
 
80
        os.chdir('gitbranch')
 
81
        builder = tests.GitBranchBuilder()
 
82
        builder.set_file('a', 'text for a\n', False)
 
83
        builder.commit('Joe Foo <joe@foo.com>', u'<The commit message>')
 
84
        builder.finish()
 
85
        os.chdir('..')
 
86
 
 
87
        output, error = self.run_bzr(['checkout', 'gitbranch', 'bzrbranch'])
 
88
        self.assertEqual(error, '')
57
89
        self.assertEqual(output, '')
58
90
 
59
91
    def test_branch_ls(self):
63
95
        self.assertEqual(output, "a\n")
64
96
 
65
97
    def test_init(self):
66
 
        self.run_bzr("init-repo --git repo") 
 
98
        self.run_bzr("init --git repo")
67
99
 
68
100
    def test_info_verbose(self):
69
101
        self.simple_commit()
70
102
 
 
103
        if bzrlib_version < (2, 4):
 
104
            raise KnownFailure("bzr info uses inventory on bzr < 2.4")
 
105
 
71
106
        output, error = self.run_bzr(['info', '-v'])
72
107
        self.assertEqual(error, '')
73
 
        self.assertTrue("Repository tree (format: git)" in output)
 
108
        self.assertTrue("Standalone tree (format: git)" in output)
74
109
        self.assertTrue("control: Local Git Repository" in output)
75
110
        self.assertTrue("branch: Git Branch" in output)
76
111
        self.assertTrue("repository: Git Repository" in output)
77
112
 
 
113
    def with_roundtripping(self):
 
114
        self.addCleanup(mapping_registry.set_default, mapping_registry.get().revid_prefix)
 
115
        mapping_registry.set_default('git-experimental')
 
116
 
 
117
    def test_push_roundtripping(self):
 
118
        self.with_roundtripping()
 
119
        os.mkdir("bla")
 
120
        GitRepo.init(os.path.join(self.test_dir, "bla"))
 
121
        self.run_bzr(['init', 'foo'])
 
122
        self.run_bzr(['commit', '--unchanged', '-m', 'bla', 'foo'])
 
123
        # when roundtripping is supported
 
124
        output, error = self.run_bzr(['push', '-d', 'foo', 'bla'])
 
125
        self.assertEquals("", output)
 
126
        self.assertTrue(error.endswith("Created new branch.\n"))
 
127
 
78
128
    def test_log(self):
79
129
        # Smoke test for "bzr log" in a git repository.
80
130
        self.simple_commit()
94
144
        output, error = self.run_bzr(['log', '-v'])
95
145
 
96
146
    def test_tags(self):
97
 
        self.simple_commit()
98
 
 
99
 
        tests.run_git("tag", "foo")
 
147
        git_repo, commit_sha1 = self.simple_commit()
 
148
        git_repo.refs["refs/tags/foo"] = commit_sha1
100
149
 
101
150
        output, error = self.run_bzr(['tags'])
102
151
        self.assertEquals(error, '')
103
152
        self.assertEquals(output, "foo                  1\n")
104
153
 
105
154
    def test_tag(self):
106
 
        raise KnownFailure("setting tags not supported by git-python yet")
107
155
        self.simple_commit()
108
156
 
109
157
        output, error = self.run_bzr(["tag", "bar"])
110
158
 
 
159
        # bzr <= 2.2 emits this message in the output stream
 
160
        # bzr => 2.3 emits this message in the error stream
 
161
        self.assertEquals(error + output, 'Created tag bar.\n')
 
162
 
 
163
    def test_init_repo(self):
 
164
        output, error = self.run_bzr(["init", "--git", "bla.git"])
111
165
        self.assertEquals(error, '')
112
 
        self.assertEquals(output, '')
 
166
        self.assertEquals(output, 'Created a standalone tree (format: git)\n')
113
167