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

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, 3 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..851c8523fc88df19725d66608059de7350279776 100755
--- a/tests/bot_update_coverage_test.py
+++ b/tests/bot_update_coverage_test.py
@@ -7,6 +7,7 @@ import codecs
import copy
import json
import os
+import subprocess
import sys
import unittest
@@ -162,6 +163,15 @@ def fake_git(*args, **kwargs):
return bot_update.call('git', *args, **kwargs)
+class MockSubprocess():
+ def __init__(self):
+ self.calls = []
+
+ def call(self, command):
+ self.calls.append(command)
+ return 0
+
+
class BotUpdateUnittests(unittest.TestCase):
def setUp(self):
self.filesystem = FakeFilesystem()
@@ -180,11 +190,17 @@ class BotUpdateUnittests(unittest.TestCase):
self.old_codecs_open = codecs.open
setattr(codecs, 'open', self.filesystem.open)
+ self.subprocess = MockSubprocess()
+ self.old_sp_call = subprocess.call
+ setattr(subprocess, 'call', self.subprocess.call)
+
def tearDown(self):
setattr(bot_update, 'call', self.old_call)
setattr(os, 'getcwd', self.old_os_cwd)
delattr(bot_update, 'open')
setattr(codecs, 'open', self.old_codecs_open)
+ delattr(subprocess, 'call')
+ setattr(subprocess, 'call', self.old_sp_call)
def testBasic(self):
bot_update.ensure_checkout(**self.params)
@@ -195,6 +211,16 @@ class BotUpdateUnittests(unittest.TestCase):
bot_update.ensure_checkout(**self.params)
return self.call.records
+ def testMaybeRemoveWinLockfile(self):
+ git_lockfile_err = '''
+ fatal: Unable to create 'E:/b/c/b/win/src/.git/index.lock': File exists.
+ '''
+ bot_update.maybe_remove_win_lockfile('win32', git_lockfile_err)
+ self.assertEqual(
+ self.subprocess.calls,
+ [['cmd.exe', '/c', 'del', '/f',
+ '/q', 'E:/b/c/b/win/src/.git/index.lock']])
+
if __name__ == '__main__':
unittest.main()

Powered by Google App Engine
This is Rietveld 408576698