/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

UseĀ get_file_revision.

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