diff --git a/tools_webrtc/autoroller/roll_deps.py b/tools_webrtc/autoroller/roll_deps.py index 445b91dfa0..4a9c90c31d 100755 --- a/tools_webrtc/autoroller/roll_deps.py +++ b/tools_webrtc/autoroller/roll_deps.py @@ -189,6 +189,12 @@ def _RunCommand(command, return std_output, err_output +def _IsExistingDir(path): + """Returns True if `path` exists and is a dir. + """ + return os.path.isdir(path) + + def _GetBranches(): """Returns a tuple of active,branches. @@ -620,7 +626,7 @@ def UpdateDepsFile(deps_filename, rev_update, changed_deps, new_cr_content): if isinstance(dep, ChangedVersionEntry): continue local_dep_dir = os.path.join(GCLIENT_ROOT_DIR, dep.path) - if not os.path.isdir(local_dep_dir): + if not _IsExistingDir(local_dep_dir): raise RollError( 'Cannot find local directory %s. Either run\n' 'gclient sync --deps=all\n' diff --git a/tools_webrtc/autoroller/unittests/roll_deps_test.py b/tools_webrtc/autoroller/unittests/roll_deps_test.py index 69f9aebf0b..fed0238f60 100755 --- a/tools_webrtc/autoroller/unittests/roll_deps_test.py +++ b/tools_webrtc/autoroller/unittests/roll_deps_test.py @@ -85,6 +85,13 @@ class NullCmd: return None, None +class MockIsExistingDir: + """Pretends that all paths are valid directories.""" + + def __call__(self, *args, **kwargs): + return True + + class TestRollChromiumRevision(unittest.TestCase): def setUp(self): @@ -134,9 +141,10 @@ class TestRollChromiumRevision(unittest.TestCase): changed_deps = CalculateChangedDeps(webrtc_deps, new_cr_deps) with mock.patch('roll_deps._RunCommand', NullCmd()): - UpdateDepsFile(self._webrtc_depsfile_android, - NO_CHROMIUM_REVISION_UPDATE, changed_deps, - new_cr_contents) + with mock.patch('roll_deps._IsExistingDir', MockIsExistingDir()): + UpdateDepsFile(self._webrtc_depsfile_android, + NO_CHROMIUM_REVISION_UPDATE, changed_deps, + new_cr_contents) with open(self._webrtc_depsfile_android, 'rb') as deps_file: updated_contents = deps_file.read().decode('utf-8')