From fca5339456c3825dbe3c17a57e4723a620716833 Mon Sep 17 00:00:00 2001 From: "maruel@chromium.org" Date: Tue, 21 Dec 2010 18:42:57 +0000 Subject: [PATCH] Workaround the fact that pylint calls sys.exit(). Otherwise the following presubmit checks where never called. TBR=nsylvain BUG= TEST=fixes unit tests Review URL: http://codereview.chromium.org/5995003 git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@69844 0039d316-1c4b-4281-b951-d872f2087c98 --- presubmit_canned_checks.py | 10 +++++++--- trychange.py | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py index 51dfcff37..bfbf52e94 100644 --- a/presubmit_canned_checks.py +++ b/presubmit_canned_checks.py @@ -494,9 +494,10 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None): # were listed, try to run pylint. try: from pylint import lint - if lint.Run(sorted(files)): - return [output_api.PresubmitPromptWarning('Fix pylint errors first.')] - return [] + result = lint.Run(sorted(files)) + except SystemExit, e: + # pylint has the bad habit of calling sys.exit(), trap it here. + result = e.code except ImportError: if input_api.platform == 'win32': return [output_api.PresubmitNotifyResult( @@ -507,6 +508,9 @@ def RunPylint(input_api, output_api, white_list=None, black_list=None): 'Please install pylint with "sudo apt-get install python-setuptools; ' 'sudo easy_install pylint"\n' 'Cannot do static analysis of python files.')] + if result: + return [output_api.PresubmitPromptWarning('Fix pylint errors first.')] + return [] finally: warnings.filterwarnings('default', category=DeprecationWarning) diff --git a/trychange.py b/trychange.py index 0360d4fa4..88129e72b 100755 --- a/trychange.py +++ b/trychange.py @@ -656,7 +656,7 @@ def TryChange(argv, checkouts = [] path = os.getcwd() if options.upstream_branch: - path += '@' + options.upstream_branch + path += '@' + options.upstream_branch checkouts.append(GuessVCS(options, path)) checkouts[0].AutomagicalSettings() for item in options.sub_rep: