Revert "presubmit_canned_checks: Run pylint on parent directory for depot_tools."

This reverts commit d3bfd23c6d.

Reason for revert: Breaks non-depot_tools based presubmits that use canned checks that expect the presubmit to be run in the sub-repository (for example, in Catapult where it's hosted in third_party/catapult instead of being directly in chromium).

Original change's description:
> presubmit_canned_checks: Run pylint on parent directory for depot_tools.
> 
> On Windows, scripts on the current directory take precedence over PATH.
> When pylint.bat calls vpython, it executes the vpython of the depot_tools
> under test instead of the one in the bot.
> As a workaround, run the tests from the parent directory instead.
> 
> Change-Id: I7fa3f5b268df516194063ff39907ada18f7ef544
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1994216
> Reviewed-by: Anthony Polito <apolito@google.com>
> Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>

TBR=ehmaldonado@chromium.org,apolito@google.com

# Not skipping CQ checks because original CL landed > 1 day ago.

Change-Id: If989527a53be90e1ae32cb3fa30f5e4777824480
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1994753
Reviewed-by: Dean Berris <dberris@chromium.org>
Reviewed-by: Edward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Dean Berris <dberris@chromium.org>
changes/53/1994753/2
Dean Berris 5 years ago committed by LUCI CQ
parent 5e96ad12ac
commit a1266b63b5

@ -885,15 +885,7 @@ def GetPylint(input_api, output_api, white_list=None, black_list=None,
# the interpreter to use. It also has limitations on the size of
# the command-line, so we pass arguments via a pipe.
tool = input_api.os_path.join(_HERE, 'pylint')
cwd = input_api.change.RepositoryRoot()
if input_api.platform == 'win32':
# On Windows, scripts on the current directory take precedence over PATH.
# When `pylint.bat` calls `vpython`, it will execute the `vpython` of the
# depot_tools under test instead of the one in the bot.
# As a workaround, we run the tests from the parent directory instead.
if input_api.os_path.basename(cwd) == 'depot_tools':
cwd = input_api.os_path.dirname(cwd)
flist = [input_api.os_path.join('depot_tools', f) for f in flist]
tool += '.bat'
cmd = [tool, '--args-on-stdin']
if len(flist) == 1:
@ -912,7 +904,7 @@ def GetPylint(input_api, output_api, white_list=None, black_list=None,
return input_api.Command(
name='Pylint (%s)' % description,
cmd=cmd,
kwargs={'env': env, 'stdin': '\n'.join(args + flist), 'cwd': cwd},
kwargs={'env': env, 'stdin': '\n'.join(args + flist)},
message=error_type)
# Always run pylint and pass it all the py files at once.

@ -2106,9 +2106,7 @@ the current line as well!
self.assertEqual(results, [])
def testCannedRunPylint(self):
change = mock.Mock()
change.RepositoryRoot.return_value = 'CWD'
input_api = self.MockInputApi(change, True)
input_api = self.MockInputApi(None, True)
input_api.environ = mock.MagicMock(os.environ)
input_api.environ.copy.return_value = {}
input_api.AffectedSourceFiles.return_value = True

Loading…
Cancel
Save