/breezy/unstable

To get this branch, use:
bzr branch https://code.breezy-vcs.org/breezy/unstable

« back to all changes in this revision

Viewing changes to breezy/tests/blackbox/test_version.py

  • Committer: Jelmer Vernooij
  • Date: 2017-05-24 01:39:33 UTC
  • mfrom: (3815.3776.6)
  • Revision ID: jelmer@jelmer.uk-20170524013933-ir4y4tqtrsiz2ka2
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
 
"""Black-box tests for bzr version."""
 
17
"""Black-box tests for brz version."""
18
18
 
19
19
import os
20
20
import sys
21
21
 
22
 
import bzrlib
23
 
from bzrlib import osutils, trace
24
 
from bzrlib.tests import (
 
22
import breezy
 
23
from breezy import osutils, trace
 
24
from breezy.tests import (
25
25
    probe_unicode_in_user_encoding,
26
26
    TestCase,
27
27
    TestCaseInTempDir,
37
37
        # can see the version being tested
38
38
        self.permit_source_tree_branch_repo()
39
39
        output = self.run_bzr('version')[0]
40
 
        self.log('bzr version output:')
 
40
        self.log('brz version output:')
41
41
        self.log(output)
42
 
        self.assertTrue(output.startswith('Bazaar (bzr) '))
 
42
        self.assertTrue(output.startswith('Breezy (brz) '))
43
43
        self.assertNotEqual(output.index('Canonical'), -1)
44
44
        # make sure --version is consistent
45
45
        tmp_output = self.run_bzr('--version')[0]
50
50
        out = self.run_bzr("version")[0]
51
51
        self.assertTrue(len(out) > 0)
52
52
        self.assertEqualDiff(out.splitlines()[0],
53
 
            "Bazaar (bzr) %s" % bzrlib.__version__)
 
53
            "Breezy (brz) %s" % breezy.__version__)
54
54
        self.assertContainsRe(out, r"(?m)^  Python interpreter:")
55
55
        self.assertContainsRe(out, r"(?m)^  Python standard library:")
56
 
        self.assertContainsRe(out, r"(?m)^  bzrlib:")
57
 
        self.assertContainsRe(out, r"(?m)^  Bazaar configuration:")
58
 
        self.assertContainsRe(out, r'(?m)^  Bazaar log file:.*\.bzr\.log')
 
56
        self.assertContainsRe(out, r"(?m)^  breezy:")
 
57
        self.assertContainsRe(out, r"(?m)^  Breezy configuration:")
 
58
        self.assertContainsRe(out, r'(?m)^  Breezy log file:.*\.brz\.log')
59
59
 
60
60
    def test_version_short(self):
61
61
        self.permit_source_tree_branch_repo()
62
62
        out = self.run_bzr(["version", "--short"])[0]
63
 
        self.assertEqualDiff(out, bzrlib.version_string + '\n')
 
63
        self.assertEqualDiff(out, breezy.version_string + '\n')
64
64
 
65
65
 
66
66
class TestVersionUnicodeOutput(TestCaseInTempDir):
67
67
 
68
68
    def _check(self, args):
69
69
        self.permit_source_tree_branch_repo()
70
 
        # Even though trace._bzr_log_filename variable
 
70
        # Even though trace._brz_log_filename variable
71
71
        # is used only to keep actual log filename
72
72
        # and changing this variable in selftest
73
 
        # don't change main .bzr.log location,
 
73
        # don't change main .brz.log location,
74
74
        # and therefore pretty safe,
75
75
        # but we run these tests in separate temp dir
76
76
        # with relative unicoded path
77
 
        old_trace_file = trace._bzr_log_filename
78
 
        trace._bzr_log_filename = u'\u1234/.bzr.log'
 
77
        old_trace_file = trace._brz_log_filename
 
78
        trace._brz_log_filename = u'\u1234/.brz.log'
79
79
        try:
80
80
            out = self.run_bzr(args)[0]
81
81
        finally:
82
 
            trace._bzr_log_filename = old_trace_file
 
82
            trace._brz_log_filename = old_trace_file
83
83
        self.assertTrue(len(out) > 0)
84
 
        self.assertContainsRe(out, r'(?m)^  Bazaar log file:.*bzr\.log')
 
84
        self.assertContainsRe(out, r'(?m)^  Breezy log file:.*brz\.log')
85
85
 
86
86
    def test_command(self):
87
87
        self._check("version")
95
95
            raise TestSkipped('Cannot find a unicode character that works in'
96
96
                              ' encoding %s' % (osutils.get_user_encoding(),))
97
97
 
98
 
        self.overrideEnv('BZR_HOME', str_val)
 
98
        self.overrideEnv('BRZ_HOME', str_val)
99
99
        self.permit_source_tree_branch_repo()
100
100
        out = self.run_bzr("version")[0]
101
101
        self.assertTrue(len(out) > 0)
102
 
        self.assertContainsRe(out, r"(?m)^  Bazaar configuration: " + str_val)
 
102
        self.assertContainsRe(out, r"(?m)^  Breezy configuration: " + str_val)
103
103
 
104
104
 
105
105
class TestVersionBzrLogLocation(TestCaseInTempDir):
106
106
 
107
107
    def test_simple(self):
108
 
        bzr_log = 'my.bzr.log'
109
 
        self.overrideEnv('BZR_LOG', bzr_log)
110
 
        default_log = os.path.join(os.environ['BZR_HOME'], '.bzr.log')
111
 
        self.assertPathDoesNotExist([default_log, bzr_log])
 
108
        brz_log = 'my.brz.log'
 
109
        self.overrideEnv('BRZ_LOG', brz_log)
 
110
        default_log = os.path.join(os.environ['BRZ_HOME'], '.brz.log')
 
111
        self.assertPathDoesNotExist([default_log, brz_log])
112
112
        out = self.run_bzr_subprocess('version')[0]
113
113
        self.assertTrue(len(out) > 0)
114
 
        self.assertContainsRe(out, r"(?m)^  Bazaar log file: " + bzr_log)
 
114
        self.assertContainsRe(out, r"(?m)^  Breezy log file: " + brz_log)
115
115
        self.assertPathDoesNotExist(default_log)
116
 
        self.assertPathExists(bzr_log)
 
116
        self.assertPathExists(brz_log)
117
117
 
118
118
    def test_dev_null(self):
119
119
        # This test uses a subprocess to cause the log opening logic to
120
120
        # execute. It would be better to just execute that logic directly.
121
121
        if sys.platform == 'win32':
122
 
            bzr_log = 'NUL'
 
122
            brz_log = 'NUL'
123
123
        else:
124
 
            bzr_log = '/dev/null'
125
 
        self.overrideEnv('BZR_LOG', bzr_log)
126
 
        default_log = os.path.join(os.environ['BZR_HOME'], '.bzr.log')
 
124
            brz_log = '/dev/null'
 
125
        self.overrideEnv('BRZ_LOG', brz_log)
 
126
        default_log = os.path.join(os.environ['BRZ_HOME'], '.brz.log')
127
127
        self.assertPathDoesNotExist(default_log)
128
128
        out = self.run_bzr_subprocess('version')[0]
129
129
        self.assertTrue(len(out) > 0)
130
 
        self.assertContainsRe(out, r"(?m)^  Bazaar log file: " + bzr_log)
 
130
        self.assertContainsRe(out, r"(?m)^  Breezy log file: " + brz_log)
131
131
        self.assertPathDoesNotExist(default_log)
132
132
 
133
 
    def test_unicode_bzr_log(self):
 
133
    def test_unicode_brz_log(self):
134
134
        uni_val = u"\xa7"
135
135
        enc = osutils.get_user_encoding()
136
136
        try:
137
137
            str_val = uni_val.encode(enc)
138
138
        except UnicodeEncodeError:
139
 
            self.skip("Test string %r unrepresentable in user encoding %s" % (
 
139
            self.skipTest(
 
140
                "Test string %r unrepresentable in user encoding %s" % (
140
141
                uni_val, enc))
141
 
        self.overrideEnv('BZR_HOME', self.test_base_dir)
142
 
        self.overrideEnv("BZR_LOG",
 
142
        self.overrideEnv('BRZ_HOME', self.test_base_dir)
 
143
        self.overrideEnv("BRZ_LOG",
143
144
            os.path.join(self.test_base_dir, uni_val).encode(enc))
144
145
        out, err = self.run_bzr_subprocess("version")
145
146
        uni_out = out.decode(enc)
146
 
        self.assertContainsRe(uni_out, u"(?m)^  Bazaar log file: .*/\xa7$")
147
 
 
148
 
 
 
147
        self.assertContainsRe(uni_out, u"(?m)^  Breezy log file: .*/\xa7$")