/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

Fix more tests.

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