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() |