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

Unified Diff: tests/bot_update_coverage_test.py

Issue 2454463002: Make bot_update on win more resilient (Closed)
Patch Set: Make bot_update on win more resilient 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « recipe_modules/bot_update/resources/bot_update.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/bot_update_coverage_test.py
diff --git a/tests/bot_update_coverage_test.py b/tests/bot_update_coverage_test.py
index 9b7715e4e4afe73a06f8434818d50e1c01f17509..f808c633ad7eab194f20e645d67a3bc0bd36e865 100755
--- a/tests/bot_update_coverage_test.py
+++ b/tests/bot_update_coverage_test.py
@@ -186,6 +186,10 @@ class BotUpdateUnittests(unittest.TestCase):
delattr(bot_update, 'open')
setattr(codecs, 'open', self.old_codecs_open)
+ def overrideSetupForWindows(self):
+ sys.platform = 'win'
+ self.call.expect(('gclient.bat', 'sync')).returns(self.gclient)
+
def testBasic(self):
bot_update.ensure_checkout(**self.params)
return self.call.records
@@ -196,8 +200,7 @@ class BotUpdateUnittests(unittest.TestCase):
return self.call.records
def testBreakLocks(self):
- sys.platform = 'win'
- self.call.expect(('gclient.bat', 'sync')).returns(self.gclient)
+ self.overrideSetupForWindows()
bot_update.ensure_checkout(**self.params)
gclient_sync_cmd = None
for record in self.call.records:
@@ -206,6 +209,20 @@ class BotUpdateUnittests(unittest.TestCase):
gclient_sync_cmd = args
self.assertTrue('--break_repo_locks' in gclient_sync_cmd)
+ def testGitCheckoutBreaksLocks(self):
+ self.overrideSetupForWindows()
+ path = '/b/build/slave/foo/build/.git'
+ lockfile = 'index.lock'
+ removed = []
+ old_os_walk = os.walk
+ old_os_remove = os.remove
+ setattr(os, 'walk', lambda _: [(path, None, [lockfile])])
+ setattr(os, 'remove', removed.append)
+ bot_update.ensure_checkout(**self.params)
+ setattr(os, 'walk', old_os_walk)
+ setattr(os, 'remove', old_os_remove)
+ self.assertTrue(os.path.join(path, lockfile) in removed)
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « recipe_modules/bot_update/resources/bot_update.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698