Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Side by Side Diff: tests/gclient_utils_test.py

Issue 393001: Split scm-specific functions out of gclient_scm.py to scm.py. (Closed)
Patch Set: Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « tests/gclient_test.py ('k') | tests/scm_unittest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/python
2 # Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
5
6 import re
7 import StringIO
8
9 import gclient_utils
10 from super_mox import SuperMoxTestBase
11
12 class SubprocessCallAndFilterTestCase(SuperMoxTestBase):
13 def testSubprocessCallAndFilter(self):
14 command = ['boo', 'foo', 'bar']
15 in_directory = 'bleh'
16 fail_status = None
17 pattern = 'a(.*)b'
18 test_string = 'ahah\naccb\nallo\naddb\n'
19 class Mock(object):
20 stdout = StringIO.StringIO(test_string)
21 def wait(self):
22 pass
23 kid = Mock()
24 print("\n________ running 'boo foo bar' in 'bleh'")
25 for i in test_string:
26 gclient_utils.sys.stdout.write(i)
27 gclient_utils.subprocess.Popen(
28 command, bufsize=0, cwd=in_directory,
29 shell=(gclient_utils.sys.platform == 'win32'),
30 stdout=gclient_utils.subprocess.PIPE,
31 stderr=gclient_utils.subprocess.STDOUT).AndReturn(kid)
32 self.mox.ReplayAll()
33 compiled_pattern = re.compile(pattern)
34 line_list = []
35 capture_list = []
36 def FilterLines(line):
37 line_list.append(line)
38 match = compiled_pattern.search(line)
39 if match:
40 capture_list.append(match.group(1))
41 gclient_utils.SubprocessCallAndFilter(
42 command, in_directory,
43 True, True,
44 fail_status, FilterLines)
45 self.assertEquals(line_list, ['ahah', 'accb', 'allo', 'addb'])
46 self.assertEquals(capture_list, ['cc', 'dd'])
47
48
49 if __name__ == '__main__':
50 import unittest
51 unittest.main()
52
53 # vim: ts=2:sw=2:tw=80:et:
OLDNEW
« no previous file with comments | « tests/gclient_test.py ('k') | tests/scm_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698