~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_version_info.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    def test_invalid_format(self):
27
27
        self.run_bzr('version-info', '--format', 'quijibo', retcode=3)
28
28
 
29
 
    def create_branch(self):
 
29
    def create_tree(self):
30
30
        wt = self.make_branch_and_tree('branch')
31
31
 
32
32
        self.build_tree(['branch/a'])
38
38
        wt.commit('adding b', rev_id='r2')
39
39
 
40
40
        self.revisions = wt.branch.revision_history()
 
41
        return wt
41
42
 
42
43
    def test_basic(self):
43
 
        self.create_branch()
 
44
        self.create_tree()
44
45
 
45
46
        txt = self.run_bzr('version-info', 'branch')[0]
46
47
        self.assertContainsRe(txt, 'date:')
50
51
 
51
52
    def test_all(self):
52
53
        """'--all' includes clean, revision history, and file revisions"""
53
 
        self.create_branch()
 
54
        self.create_tree()
54
55
        txt = self.run_bzr('version-info', 'branch',
55
56
                           '--all')[0]
56
57
        self.assertContainsRe(txt, 'date:')
68
69
 
69
70
    def test_clean(self):
70
71
        """Test that --check-clean includes the right info"""
71
 
        self.create_branch()
 
72
        self.create_tree()
72
73
 
73
74
        txt = self.run_bzr('version-info', 'branch',
74
75
                           '--check-clean')[0]
85
86
 
86
87
        os.remove('branch/c')
87
88
 
 
89
    def test_no_working_tree(self):
 
90
        tree = self.create_tree()
 
91
        branch = self.make_branch('just_branch')
 
92
        branch.pull(tree.branch)
 
93
 
 
94
        txt = self.run_bzr('version-info', 'just_branch')[0]
 
95
        self.assertStartsWith(txt, 'revision-id: r2\n')
 
96
 
 
97
    def assertEqualNoBuildDate(self, text1, text2):
 
98
        """Compare 2 texts, but ignore the build-date field.
 
99
 
 
100
        build-date is the current timestamp, accurate to seconds. But the
 
101
        clock is always ticking, and it may have ticked between the time
 
102
        that text1 and text2 were generated.
 
103
        """
 
104
        lines1 = text1.splitlines(True)
 
105
        lines2 = text2.splitlines(True)
 
106
        for line1, line2 in zip(lines1, lines2):
 
107
            if line1.startswith('build-date: '):
 
108
                self.assertStartsWith(line2, 'build-date: ')
 
109
            else:
 
110
                self.assertEqual(line1, line2)
 
111
        self.assertEqual(len(lines1), len(lines2))
 
112
 
88
113
    def test_no_branch(self):
89
114
        """Test that bzr defaults to the local working directory"""
90
 
        self.create_branch()
 
115
        self.create_tree()
91
116
 
92
117
        txt1 = self.run_bzr('version-info', 'branch')[0]
93
118
 
94
119
        os.chdir('branch')
95
120
        txt2 = self.run_bzr('version-info')[0]
96
 
        self.assertEqual(txt1, txt2)
 
121
        self.assertEqualNoBuildDate(txt1, txt2)
97
122
 
98
123
    def test_rio(self):
99
124
        """Test that we can pass --format=rio"""
100
 
        self.create_branch()
 
125
        self.create_tree()
101
126
 
102
127
        txt = self.run_bzr('version-info', 'branch')[0]
103
128
        txt1 = self.run_bzr('version-info', '--format', 'rio', 'branch')[0]
104
129
        txt2 = self.run_bzr('version-info', '--format=rio', 'branch')[0]
105
 
        self.assertEqual(txt, txt1)
106
 
        self.assertEqual(txt, txt2)
 
130
        self.assertEqualNoBuildDate(txt, txt1)
 
131
        self.assertEqualNoBuildDate(txt, txt2)
107
132
 
108
133
    def test_python(self):
109
134
        """Test that we can do --format=python"""
110
 
        self.create_branch()
 
135
        self.create_tree()
111
136
 
112
137
        txt = self.run_bzr('version-info', '--format', 'python', 'branch')[0]
113
138