OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2010 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 re | |
7 import StringIO | 6 import StringIO |
8 | 7 |
| 8 # Fixes include path. |
| 9 from super_mox import SuperMoxTestBase |
| 10 |
9 import gclient_utils | 11 import gclient_utils |
10 from super_mox import SuperMoxTestBase | |
11 | 12 |
12 | 13 |
13 class GclientUtilsUnittest(SuperMoxTestBase): | 14 class GclientUtilsUnittest(SuperMoxTestBase): |
14 """General gclient_utils.py tests.""" | 15 """General gclient_utils.py tests.""" |
15 def testMembersChanged(self): | 16 def testMembersChanged(self): |
16 members = [ | 17 members = [ |
17 'CheckCall', 'CheckCallError', 'Error', 'FileRead', 'FileWrite', | 18 'CheckCall', 'CheckCallError', 'Error', 'FileRead', 'FileWrite', |
18 'FindGclientRoot', 'GetNamedNodeText', | 19 'FindGclientRoot', 'GetNamedNodeText', |
19 'GetNodeNamedAttributeText', 'IsUsingGit', 'PathDifference', | 20 'GetNodeNamedAttributeText', 'IsUsingGit', 'PathDifference', |
20 'ParseXML', 'PrintableObject', 'RemoveDirectory', 'SplitUrlRevision', | 21 'ParseXML', 'PrintableObject', 'RemoveDirectory', 'SplitUrlRevision', |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 kid = Mock() | 76 kid = Mock() |
76 print("\n________ running 'boo foo bar' in 'bleh'") | 77 print("\n________ running 'boo foo bar' in 'bleh'") |
77 for i in test_string: | 78 for i in test_string: |
78 gclient_utils.sys.stdout.write(i) | 79 gclient_utils.sys.stdout.write(i) |
79 gclient_utils.subprocess.Popen( | 80 gclient_utils.subprocess.Popen( |
80 command, bufsize=0, cwd=in_directory, | 81 command, bufsize=0, cwd=in_directory, |
81 shell=(gclient_utils.sys.platform == 'win32'), | 82 shell=(gclient_utils.sys.platform == 'win32'), |
82 stdout=gclient_utils.subprocess.PIPE, | 83 stdout=gclient_utils.subprocess.PIPE, |
83 stderr=gclient_utils.subprocess.STDOUT).AndReturn(kid) | 84 stderr=gclient_utils.subprocess.STDOUT).AndReturn(kid) |
84 self.mox.ReplayAll() | 85 self.mox.ReplayAll() |
85 compiled_pattern = re.compile(pattern) | 86 compiled_pattern = gclient_utils.re.compile(pattern) |
86 line_list = [] | 87 line_list = [] |
87 capture_list = [] | 88 capture_list = [] |
88 def FilterLines(line): | 89 def FilterLines(line): |
89 line_list.append(line) | 90 line_list.append(line) |
90 match = compiled_pattern.search(line) | 91 match = compiled_pattern.search(line) |
91 if match: | 92 if match: |
92 capture_list.append(match.group(1)) | 93 capture_list.append(match.group(1)) |
93 gclient_utils.SubprocessCallAndFilter( | 94 gclient_utils.SubprocessCallAndFilter( |
94 command, in_directory, | 95 command, in_directory, |
95 True, True, | 96 True, True, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 out_url, out_rev = gclient_utils.SplitUrlRevision("%s@%s" % (url, rev)) | 137 out_url, out_rev = gclient_utils.SplitUrlRevision("%s@%s" % (url, rev)) |
137 self.assertEquals(out_rev, rev) | 138 self.assertEquals(out_rev, rev) |
138 self.assertEquals(out_url, url) | 139 self.assertEquals(out_url, url) |
139 | 140 |
140 | 141 |
141 if __name__ == '__main__': | 142 if __name__ == '__main__': |
142 import unittest | 143 import unittest |
143 unittest.main() | 144 unittest.main() |
144 | 145 |
145 # vim: ts=2:sw=2:tw=80:et: | 146 # vim: ts=2:sw=2:tw=80:et: |
OLD | NEW |