From 1037c743e33821d9aebda2624be4cc2a9a35c21d Mon Sep 17 00:00:00 2001 From: Edward Lemur Date: Tue, 1 May 2018 18:56:04 -0400 Subject: [PATCH] presubmit: Don't overwrite cwd when running tests. Sometimes 'cwd' has already been specified, for example by GetPythonUnitTests. Don't overwrite it if it has been. TBR=agable@chromium.org Bug: 829084 Change-Id: Ide65c2811bcdd2628d4e886227d634dc66bfd297 Reviewed-on: https://chromium-review.googlesource.com/1038665 Reviewed-by: Edward Lesmes Commit-Queue: Edward Lesmes --- presubmit_support.py | 3 ++- tests/presubmit_unittest.py | 3 --- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/presubmit_support.py b/presubmit_support.py index 0da80ff77c..4148b704c7 100755 --- a/presubmit_support.py +++ b/presubmit_support.py @@ -785,7 +785,8 @@ class InputApi(object): tests.append(t) if self.verbose: t.info = _PresubmitNotifyResult - t.kwargs['cwd'] = self.PresubmitLocalPath() + if not t.kwargs.get('cwd'): + t.kwargs['cwd'] = self.PresubmitLocalPath() self.thread_pool.AddTests(tests, parallel) if not self.parallel: msgs.extend(self.thread_pool.RunAsync()) diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 18402b0e38..f4719859bf 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -2785,8 +2785,6 @@ class CannedChecksUnittest(PresubmitTestsBase): input_api = self.MockInputApi(change, False) input_api.verbose = True unit_tests = ['allo', 'bar.py'] - input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) - input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) cmd = ['bar.py', '--verbose'] if input_api.platform == 'win32': cmd.insert(0, 'vpython.bat') @@ -2814,7 +2812,6 @@ class CannedChecksUnittest(PresubmitTestsBase): input_api.verbose = True input_api.logging = self.mox.CreateMock(logging) input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) - input_api.PresubmitLocalPath().AndReturn(self.fake_root_dir) path = presubmit.os.path.join(self.fake_root_dir, 'random_directory') input_api.os_listdir(path).AndReturn(['.', '..', 'a', 'b', 'c']) input_api.os_path.isfile = lambda x: not x.endswith('.')