2052.3.1
by John Arbash Meinel
Add tests to cleanup the copyright of all source files |
1 |
# Copyright (C) 2005, 2006 Canonical Ltd
|
2 |
#
|
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
16 |
"""Black-box tests for default log_formats/log_formatters
|
17 |
"""
|
|
18 |
||
19 |
import os |
|
20 |
||
21 |
from bzrlib.branch import Branch |
|
22 |
from bzrlib.tests import TestCaseInTempDir |
|
1551.2.48
by abentley
Used ensure_config_dir exists instead of makedirs |
23 |
from bzrlib.config import (ensure_config_dir_exists, config_filename) |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
24 |
|
25 |
||
26 |
class TestLogFormats(TestCaseInTempDir): |
|
27 |
||
28 |
def bzr(self, *args, **kwargs): |
|
29 |
return self.run_bzr(*args, **kwargs)[0] |
|
30 |
||
31 |
def test_log_default_format(self): |
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
32 |
self.setup_config() |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
33 |
|
34 |
self.bzr('init') |
|
35 |
open('a', 'wb').write('foo\n') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
36 |
self.bzr('add a') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
37 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
38 |
self.bzr('commit -m 1') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
39 |
open('a', 'wb').write('baz\n') |
40 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
41 |
self.bzr('commit -m 2') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
42 |
|
43 |
# only the lines formatter is this short
|
|
44 |
self.assertEquals(3, len(self.bzr('log').split('\n'))) |
|
45 |
||
46 |
def test_log_format_arg(self): |
|
47 |
self.bzr('init') |
|
48 |
open('a', 'wb').write('foo\n') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
49 |
self.bzr('add a') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
50 |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
51 |
self.bzr('commit -m 1') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
52 |
open('a', 'wb').write('baz\n') |
53 |
||
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
54 |
self.bzr('commit -m 2') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
55 |
|
56 |
# only the lines formatter is this short
|
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
57 |
self.assertEquals(7, len(self.bzr('log --log-format short').split('\n'))) |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
58 |
|
59 |
def test_missing_default_format(self): |
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
60 |
self.setup_config() |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
61 |
|
62 |
os.mkdir('a') |
|
63 |
os.chdir('a') |
|
64 |
self.bzr('init') |
|
65 |
||
66 |
open('a', 'wb').write('foo\n') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
67 |
self.bzr('add a') |
68 |
self.bzr('commit -m 1') |
|
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
69 |
|
70 |
os.chdir('..') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
71 |
self.bzr('branch a b') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
72 |
os.chdir('a') |
73 |
||
74 |
open('a', 'wb').write('bar\n') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
75 |
self.bzr('commit -m 2') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
76 |
|
77 |
open('a', 'wb').write('baz\n') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
78 |
self.bzr('commit -m 3') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
79 |
|
80 |
os.chdir('../b') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
81 |
|
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
82 |
self.assertEquals(5, len(self.bzr('missing', retcode=1).split('\n'))) |
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
83 |
|
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
84 |
os.chdir('..') |
85 |
||
86 |
def test_missing_format_arg(self): |
|
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
87 |
self.setup_config() |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
88 |
|
89 |
os.mkdir('a') |
|
90 |
os.chdir('a') |
|
91 |
self.bzr('init') |
|
92 |
||
93 |
open('a', 'wb').write('foo\n') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
94 |
self.bzr('add a') |
95 |
self.bzr('commit -m 1') |
|
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
96 |
|
97 |
os.chdir('..') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
98 |
self.bzr('branch a b') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
99 |
os.chdir('a') |
100 |
||
101 |
open('a', 'wb').write('bar\n') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
102 |
self.bzr('commit -m 2') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
103 |
|
104 |
open('a', 'wb').write('baz\n') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
105 |
self.bzr('commit -m 3') |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
106 |
|
107 |
os.chdir('../b') |
|
2552.2.3
by Vincent Ladeuil
Deprecate the varargs syntax and fix the tests. |
108 |
|
109 |
self.assertEquals(9, len(self.bzr('missing --log-format short', |
|
110 |
retcode=1).split('\n'))) |
|
111 |
||
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
112 |
os.chdir('..') |
113 |
||
114 |
||
1773.4.1
by Martin Pool
Add pyflakes makefile target; fix many warnings |
115 |
def setup_config(self): |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
116 |
if os.path.isfile(config_filename()): |
117 |
# Something is wrong in environment,
|
|
118 |
# we risk overwriting users config
|
|
119 |
self.assert_(config_filename() + "exists, abort") |
|
120 |
||
1551.2.48
by abentley
Used ensure_config_dir exists instead of makedirs |
121 |
ensure_config_dir_exists() |
1553.2.11
by Erik Bågfors
blackbox tests for default log format and log-format arguments |
122 |
CONFIG=("[DEFAULT]\n" |
123 |
"email=Joe Foo <joe@foo.com>\n" |
|
124 |
"log_format=line\n") |
|
125 |
||
126 |
open(config_filename(),'wb').write(CONFIG) |