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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: tests/bot_update_coverage_test.py
diff --git a/tests/bot_update_coverage_test.py b/tests/bot_update_coverage_test.py
index f055a9ba64b64c296420cf64bfa3ca39cbda4347..0948e81311396f613f7f71b39f87287381186f5a 100755
--- a/tests/bot_update_coverage_test.py
+++ b/tests/bot_update_coverage_test.py
@@ -175,6 +175,8 @@ class BotUpdateUnittests(unittest.TestCase):
self.old_os_cwd = os.getcwd
setattr(os, 'getcwd', lambda: '/b/build/slave/foo/build')
+ self.old_os_listdir = os.listdir
+ setattr(os, 'listdir', lambda _: ['a.lock', 'b.lock', 'c.txt'])
setattr(bot_update, 'open', self.filesystem.open)
self.old_codecs_open = codecs.open
@@ -183,6 +185,7 @@ class BotUpdateUnittests(unittest.TestCase):
def tearDown(self):
setattr(bot_update, 'call', self.old_call)
setattr(os, 'getcwd', self.old_os_cwd)
+ setattr(os, 'listdir', self.old_os_listdir)
delattr(bot_update, 'open')
setattr(codecs, 'open', self.old_codecs_open)
@@ -195,6 +198,21 @@ class BotUpdateUnittests(unittest.TestCase):
bot_update.ensure_checkout(**self.params)
return self.call.records
+ def testRemoveGitLockfiles(self):
+ bot_update.remove_git_lockfiles('win32', 'E:/b/c/b/win/src',1)
+ self.assertTrue((('cmd.exe', '/c', 'del', '/f', '/q',
+ 'E:/b/c/b/win/src/.git/a.lock'), {}) in self.call.records)
+ self.assertTrue((('cmd.exe', '/c', 'del', '/f', '/q',
+ 'E:/b/c/b/win/src/.git/b.lock'), {}) in self.call.records)
+ self.assertFalse((('cmd.exe', '/c', 'del', '/f', '/q',
+ 'E:/b/c/b/win/src/.git/c.txt'), {}) in self.call.records)
+
+ def testRemoveGitLockfilesInBadDirectory(self):
+ setattr(os, 'listdir', self.old_os_listdir)
+ # If a directory doesn't exist, we don't want this method to raise an
+ # Exception
+ self.assertEqual(bot_update.remove_git_lockfiles(
+ 'win32', 'this/dir/does/not/exist'), None)
if __name__ == '__main__':
unittest.main()

Powered by Google App Engine
This is Rietveld 408576698