Fix a concurrency issue happening with deep dependencies when the intermediary
directory doesn't exist, on fresh checkout and --jobs >1.
It happens in the case where there is 3 dependencies:
a
a/b/c/d
a/b/c/e
'a' is processed first. Then 'a/b/c/d' and 'a/b/c/e' are fired simultaneously.
If both are not present, both svn checkout tries to mkdir b and b/c and a race
condition occurs between their call for isdir() and mkdir().
This works around the issue by creating the intermediary directories ourself
before calling out svn and managing the error ourself.
TBR=dpranke@chromium.org
BUG=
TEST=fresh checkout shouldn't be flaky
Review URL: http://codereview.chromium.org/8359018
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@106636 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/tests/gclient_scm_test.py b/tests/gclient_scm_test.py
index c69ad2f..44d23aa 100755
--- a/tests/gclient_scm_test.py
+++ b/tests/gclient_scm_test.py
@@ -142,6 +142,10 @@
gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
# Checkout.
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
+ parent = gclient_scm.os.path.dirname(self.base_path)
+ gclient_scm.os.path.exists(parent).AndReturn(False)
+ gclient_scm.os.makedirs(parent)
+ gclient_scm.os.path.exists(parent).AndReturn(True)
files_list = self.mox.CreateMockAnything()
gclient_scm.scm.SVN.RunAndGetFileList(
options.verbose,
@@ -167,6 +171,10 @@
gclient_scm.os.path.exists(join(self.base_path, '.git')).AndReturn(False)
gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
+ parent = gclient_scm.os.path.dirname(self.base_path)
+ gclient_scm.os.path.exists(parent).AndReturn(False)
+ gclient_scm.os.makedirs(parent)
+ gclient_scm.os.path.exists(parent).AndReturn(True)
files_list = self.mox.CreateMockAnything()
gclient_scm.scm.SVN.Capture(['--version']).AndReturn('svn, version 1.6')
gclient_scm.scm.SVN.RunAndGetFileList(
@@ -255,6 +263,10 @@
gclient_scm.os.path.exists(join(self.base_path, '.hg')).AndReturn(False)
# Checkout.
gclient_scm.os.path.exists(self.base_path).AndReturn(False)
+ parent = gclient_scm.os.path.dirname(self.base_path)
+ gclient_scm.os.path.exists(parent).AndReturn(False)
+ gclient_scm.os.makedirs(parent)
+ gclient_scm.os.path.exists(parent).AndReturn(True)
files_list = self.mox.CreateMockAnything()
gclient_scm.scm.SVN.Capture(['--version']
).AndReturn('svn, version 1.5.1 (r32289)')