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

Side by Side Diff: tests/bot_update_coverage_test.py

Issue 2382653005: Remove git lockfile flakiness on win (bot_update) (Closed)
Patch Set: Remove git lockfile flakiness on win (bot_update) Created 4 years, 2 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2015 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2015 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 codecs 6 import codecs
7 import copy 7 import copy
8 import json 8 import json
9 import os 9 import os
10 import sys 10 import sys
11 import unittest 11 import unittest
12 12
13 #import test_env # pylint: disable=W0403,W0611 13 #import test_env # pylint: disable=W0403,W0611
14 14
15 sys.path.insert(0, os.path.join( 15 sys.path.insert(0, os.path.join(
16 os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 16 os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
17 'recipe_modules', 'bot_update', 'resources')) 17 'recipe_modules', 'bot_update', 'resources'))
18 sys.platform = 'linux2' # For consistency, ya know?
19 import bot_update 18 import bot_update
20 19
21 DEFAULT_PARAMS = { 20 DEFAULT_PARAMS = {
22 'solutions': [{ 21 'solutions': [{
23 'name': 'somename', 22 'name': 'somename',
24 'url': 'https://fake.com' 23 'url': 'https://fake.com'
25 }], 24 }],
26 'revisions': [], 25 'revisions': [],
27 'first_sln': 'somename', 26 'first_sln': 'somename',
28 'target_os': None, 27 'target_os': None,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 return self.files[target] 156 return self.files[target]
158 return self.files[target] 157 return self.files[target]
159 158
160 159
161 def fake_git(*args, **kwargs): 160 def fake_git(*args, **kwargs):
162 return bot_update.call('git', *args, **kwargs) 161 return bot_update.call('git', *args, **kwargs)
163 162
164 163
165 class BotUpdateUnittests(unittest.TestCase): 164 class BotUpdateUnittests(unittest.TestCase):
166 def setUp(self): 165 def setUp(self):
166 sys.platform = 'linux2' # For consistency, ya know?
167 self.filesystem = FakeFilesystem() 167 self.filesystem = FakeFilesystem()
168 self.call = MockedCall(self.filesystem) 168 self.call = MockedCall(self.filesystem)
169 self.gclient = MockedGclientSync(self.filesystem) 169 self.gclient = MockedGclientSync(self.filesystem)
170 self.call.expect(('gclient', 'sync')).returns(self.gclient) 170 self.call.expect(('gclient', 'sync')).returns(self.gclient)
171 self.old_call = getattr(bot_update, 'call') 171 self.old_call = getattr(bot_update, 'call')
172 self.params = copy.deepcopy(DEFAULT_PARAMS) 172 self.params = copy.deepcopy(DEFAULT_PARAMS)
173 setattr(bot_update, 'call', self.call) 173 setattr(bot_update, 'call', self.call)
174 setattr(bot_update, 'git', fake_git) 174 setattr(bot_update, 'git', fake_git)
175 175
176 self.old_os_cwd = os.getcwd 176 self.old_os_cwd = os.getcwd
(...skipping 11 matching lines...) Expand all
188 188
189 def testBasic(self): 189 def testBasic(self):
190 bot_update.ensure_checkout(**self.params) 190 bot_update.ensure_checkout(**self.params)
191 return self.call.records 191 return self.call.records
192 192
193 def testBasicShallow(self): 193 def testBasicShallow(self):
194 self.params['shallow'] = True 194 self.params['shallow'] = True
195 bot_update.ensure_checkout(**self.params) 195 bot_update.ensure_checkout(**self.params)
196 return self.call.records 196 return self.call.records
197 197
198 def testBreakLocks(self):
199 sys.platform = 'win'
200 self.call.expect(('gclient.bat', 'sync')).returns(self.gclient)
201 bot_update.ensure_checkout(**self.params)
202 gclient_sync_cmd = None
203 for record in self.call.records:
204 args = record[0]
205 if args[0] == 'gclient.bat' and args[1] == 'sync':
206 gclient_sync_cmd = args
207 self.assertTrue('--break_repo_locks' in gclient_sync_cmd)
208
198 209
199 if __name__ == '__main__': 210 if __name__ == '__main__':
200 unittest.main() 211 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698