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

Side by Side Diff: tests/gcl_unittest.py

Issue 115264: Deprecate gcl.GetSVNStatus() for gclient.CaptureSVNStatus() and fix some stat... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 11 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « gclient.py ('k') | tests/gclient_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/python 1 #!/usr/bin/python
2 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2009 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 """Unit tests for gcl.py.""" 6 """Unit tests for gcl.py."""
7 7
8 import StringIO 8 import StringIO
9 import os 9 import os
10 import sys 10 import sys
(...skipping 30 matching lines...) Expand all
41 41
42 class GclUnittest(GclTestsBase): 42 class GclUnittest(GclTestsBase):
43 """General gcl.py tests.""" 43 """General gcl.py tests."""
44 def testMembersChanged(self): 44 def testMembersChanged(self):
45 members = [ 45 members = [
46 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'CPP_EXTENSIONS', 46 'CODEREVIEW_SETTINGS', 'CODEREVIEW_SETTINGS_FILE', 'CPP_EXTENSIONS',
47 'Change', 'ChangeInfo', 'Changes', 'Commit', 'DoPresubmitChecks', 47 'Change', 'ChangeInfo', 'Changes', 'Commit', 'DoPresubmitChecks',
48 'ErrorExit', 'GenerateChangeName', 'GenerateDiff', 'GetCLs', 48 'ErrorExit', 'GenerateChangeName', 'GenerateDiff', 'GetCLs',
49 'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor', 49 'GetChangelistInfoFile', 'GetCodeReviewSetting', 'GetEditor',
50 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription', 50 'GetFilesNotInCL', 'GetInfoDir', 'GetIssueDescription',
51 'GetModifiedFiles', 'GetRepositoryRoot', 'GetSVNStatus', 51 'GetModifiedFiles', 'GetRepositoryRoot',
52 'GetSVNFileProperty', 'Help', 'IGNORE_PATHS', 'IsSVNMoved', 'IsTreeOpen', 52 'GetSVNFileProperty', 'Help', 'IGNORE_PATHS', 'IsSVNMoved', 'IsTreeOpen',
53 'Lint', 'LoadChangelistInfo', 'LoadChangelistInfoForMultiple', 53 'Lint', 'LoadChangelistInfo', 'LoadChangelistInfoForMultiple',
54 'MISSING_TEST_MSG', 'Opened', 'PresubmitCL', 'ReadFile', 54 'MISSING_TEST_MSG', 'Opened', 'PresubmitCL', 'ReadFile',
55 'RunShell', 55 'RunShell',
56 'RunShellWithReturnCode', 'SEPARATOR', 'SendToRietveld', 'TryChange', 56 'RunShellWithReturnCode', 'SEPARATOR', 'SendToRietveld', 'TryChange',
57 'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile', 'gclient', 57 'UnknownFiles', 'UploadCL', 'Warn', 'WriteFile', 'gclient',
58 'gcl_info_dir', 'getpass', 'main', 'os', 'random', 're', 'read_gcl_info', 58 'gcl_info_dir', 'getpass', 'main', 'os', 'random', 're', 'read_gcl_info',
59 'repository_root', 'string', 'subprocess', 'sys', 'tempfile', 'upload', 59 'repository_root', 'string', 'subprocess', 'sys', 'tempfile', 'upload',
60 'urllib2', 'xml', 60 'urllib2', 'xml',
61 ] 61 ]
62 # If this test fails, you should add the relevant test. 62 # If this test fails, you should add the relevant test.
63 self.compareMembers(gcl, members) 63 self.compareMembers(gcl, members)
64 64
65 def testGetSVNStatus(self):
66 def RunShellMock(command):
67 return r"""<?xml version="1.0"?>
68 <status>
69 <target path=".">
70 <entry path="unversionned_file.txt">
71 <wc-status props="none" item="unversioned"></wc-status>
72 </entry>
73 <entry path="build\internal\essential.vsprops">
74 <wc-status props="normal" item="modified" revision="14628">
75 <commit revision="13818">
76 <author>ajwong@chromium.org</author>
77 <date>2009-04-16T00:42:06.872358Z</date>
78 </commit>
79 </wc-status>
80 </entry>
81 <entry path="chrome\app\d">
82 <wc-status props="none" copied="true" tree-conflicted="true" item="added">
83 </wc-status>
84 </entry>
85 <entry path="chrome\app\DEPS">
86 <wc-status props="modified" item="modified" revision="14628">
87 <commit revision="1279">
88 <author>brettw@google.com</author>
89 <date>2008-08-23T17:16:42.090152Z</date>
90 </commit>
91 </wc-status>
92 </entry>
93 <entry path="scripts\master\factory\gclient_factory.py">
94 <wc-status props="normal" item="conflicted" revision="14725">
95 <commit revision="14633">
96 <author>nsylvain@chromium.org</author>
97 <date>2009-04-27T19:37:17.977400Z</date>
98 </commit>
99 </wc-status>
100 </entry>
101 </target>
102 </status>
103 """
104 # GclTestsBase.tearDown will restore the original.
105 gcl.RunShell = RunShellMock
106 info = gcl.GetSVNStatus('.')
107 expected = [
108 ('? ', 'unversionned_file.txt'),
109 ('M ', 'build\\internal\\essential.vsprops'),
110 ('A + ', 'chrome\\app\\d'),
111 ('MM ', 'chrome\\app\\DEPS'),
112 ('C ', 'scripts\\master\\factory\\gclient_factory.py'),
113 ]
114 self.assertEquals(sorted(info), sorted(expected))
115
116 def testGetSVNStatusEmpty(self):
117 def RunShellMock(command):
118 return r"""<?xml version="1.0"?>
119 <status>
120 <target
121 path="perf">
122 </target>
123 </status>
124 """
125 # GclTestsBase.tearDown will restore the original.
126 gcl.RunShell = RunShellMock
127 info = gcl.GetSVNStatus(None)
128 self.assertEquals(info, [])
129 65
130 def testHelp(self): 66 def testHelp(self):
131 old_stdout = sys.stdout 67 old_stdout = sys.stdout
132 try: 68 try:
133 dummy = StringIO.StringIO() 69 dummy = StringIO.StringIO()
134 gcl.sys.stdout = dummy 70 gcl.sys.stdout = dummy
135 gcl.Help() 71 gcl.Help()
136 self.assertEquals(len(dummy.getvalue()), 1718) 72 self.assertEquals(len(dummy.getvalue()), 1718)
137 finally: 73 finally:
138 gcl.sys.stdout = old_stdout 74 gcl.sys.stdout = old_stdout
(...skipping 25 matching lines...) Expand all
164 self.assertEquals(o.name, 'name2') 100 self.assertEquals(o.name, 'name2')
165 self.assertEquals(o.issue, 'issue2') 101 self.assertEquals(o.issue, 'issue2')
166 self.assertEquals(o.description, 'description2') 102 self.assertEquals(o.description, 'description2')
167 self.assertEquals(o.files, files) 103 self.assertEquals(o.files, files)
168 self.assertEquals(o.patch, None) 104 self.assertEquals(o.patch, None)
169 self.assertEquals(o.FileList(), ['foo', 'bar']) 105 self.assertEquals(o.FileList(), ['foo', 'bar'])
170 106
171 107
172 if __name__ == '__main__': 108 if __name__ == '__main__':
173 unittest.main() 109 unittest.main()
OLDNEW
« no previous file with comments | « gclient.py ('k') | tests/gclient_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698