OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2011 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import StringIO | 7 import StringIO |
8 import sys | 8 import sys |
9 | 9 |
10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | 10 sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
(...skipping 15 matching lines...) Expand all Loading... |
26 | 26 |
27 class GclientUtilsUnittest(GclientUtilBase): | 27 class GclientUtilsUnittest(GclientUtilBase): |
28 """General gclient_utils.py tests.""" | 28 """General gclient_utils.py tests.""" |
29 def testMembersChanged(self): | 29 def testMembersChanged(self): |
30 members = [ | 30 members = [ |
31 'Annotated', 'AutoFlush', 'CheckCallAndFilter', | 31 'Annotated', 'AutoFlush', 'CheckCallAndFilter', |
32 'CheckCallAndFilterAndHeader', 'Error', 'ExecutionQueue', 'FileRead', | 32 'CheckCallAndFilterAndHeader', 'Error', 'ExecutionQueue', 'FileRead', |
33 'FileWrite', 'FindFileUpwards', 'FindGclientRoot', | 33 'FileWrite', 'FindFileUpwards', 'FindGclientRoot', |
34 'GetGClientRootAndEntries', 'GetEditor', 'IsDateRevision', | 34 'GetGClientRootAndEntries', 'GetEditor', 'IsDateRevision', |
35 'MakeDateRevision', 'MakeFileAutoFlush', 'MakeFileAnnotated', | 35 'MakeDateRevision', 'MakeFileAutoFlush', 'MakeFileAnnotated', |
36 'PathDifference', 'PrintableObject', 'RemoveDirectory', 'RunEditor', | 36 'PathDifference', 'ParseCodereviewSettingsContent', |
| 37 'PrintableObject', 'RemoveDirectory', 'RunEditor', |
37 'SplitUrlRevision', 'SyntaxErrorToError', 'Wrapper', 'WorkItem', | 38 'SplitUrlRevision', 'SyntaxErrorToError', 'Wrapper', 'WorkItem', |
38 'errno', 'lockedmethod', 'logging', 'os', 'Queue', 're', 'rmtree', | 39 'errno', 'lockedmethod', 'logging', 'os', 'Queue', 're', 'rmtree', |
39 'safe_makedirs', 'stat', 'subprocess2', 'sys', 'tempfile', 'threading', | 40 'safe_makedirs', 'stat', 'subprocess2', 'sys', 'tempfile', 'threading', |
40 'time', | 41 'time', |
41 ] | 42 ] |
42 # If this test fails, you should add the relevant test. | 43 # If this test fails, you should add the relevant test. |
43 self.compareMembers(gclient_utils, members) | 44 self.compareMembers(gclient_utils, members) |
44 | 45 |
45 | 46 |
46 | 47 |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 f3 = os.path.join(l3, 'f3') | 164 f3 = os.path.join(l3, 'f3') |
164 os.mkdir(l1) | 165 os.mkdir(l1) |
165 os.mkdir(l2) | 166 os.mkdir(l2) |
166 os.mkdir(l3) | 167 os.mkdir(l3) |
167 gclient_utils.FileWrite(f3, 'foo') | 168 gclient_utils.FileWrite(f3, 'foo') |
168 os.chmod(f3, 0) | 169 os.chmod(f3, 0) |
169 os.chmod(l3, 0) | 170 os.chmod(l3, 0) |
170 os.chmod(l2, 0) | 171 os.chmod(l2, 0) |
171 os.chmod(l1, 0) | 172 os.chmod(l1, 0) |
172 | 173 |
| 174 def testParseCodereviewSettingsContent(self): |
| 175 expected = { |
| 176 'Foo': 'bar:baz', |
| 177 'Second': 'value', |
| 178 } |
| 179 content = ( |
| 180 '# bleh\n' |
| 181 '\t# foo : bar\n' |
| 182 'Foo:bar:baz\n' |
| 183 ' Second : value \n\r' |
| 184 '#inconsistency' |
| 185 ) |
| 186 self.assertEquals( |
| 187 expected, gclient_utils.ParseCodereviewSettingsContent(content)) |
| 188 |
173 | 189 |
174 if __name__ == '__main__': | 190 if __name__ == '__main__': |
175 import unittest | 191 import unittest |
176 unittest.main() | 192 unittest.main() |
177 | 193 |
178 # vim: ts=2:sw=2:tw=80:et: | 194 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |