From a51a06699f6ccccdd8acab7df70c8e9a9184ff80 Mon Sep 17 00:00:00 2001 From: Edward Lesmes Date: Thu, 24 Oct 2019 22:43:31 +0000 Subject: [PATCH] presubmit: Run tests on Windows. Change-Id: Ia6844cd6da6a9c68ed3d83144bd032933ab69fcf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1875110 Commit-Queue: Edward Lesmes Reviewed-by: Anthony Polito --- PRESUBMIT.py | 1 - tests/presubmit_unittest.py | 14 ++++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/PRESUBMIT.py b/PRESUBMIT.py index 00d06be04..49665899a 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -79,7 +79,6 @@ def CommonChecks(input_api, output_api, tests_to_black_list, run_on_python3): r'.*git_number_test\.py$', r'.*git_rebase_update_test\.py$', r'.*ninjalog_uploader_test\.py$', - r'.*presubmit_unittest\.py$', r'.*recipes_test\.py$', r'.*roll_dep_test\.py$', r'.*scm_unittest\.py$', diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py index 0b0cfaef4..5233ee7df 100755 --- a/tests/presubmit_unittest.py +++ b/tests/presubmit_unittest.py @@ -917,7 +917,7 @@ class InputApiUnittest(PresubmitTestsBase): known_files = [] for _, f, exists in files: full_file = os.path.join(self.fake_root_dir, f) - if exists and f.startswith('foo/'): + if exists and f.startswith('foo'): known_files.append(full_file) diffs.append(self.presubmit_diffs % {'filename': f}) @@ -2078,8 +2078,8 @@ the current line as well! input_api.environ = mock.MagicMock(os.environ) input_api.environ.copy.return_value = {} input_api.AffectedSourceFiles.return_value = True - input_api.PresubmitLocalPath.return_value = '/foo' - input_api.os_walk.return_value = [('/foo', [], ['file1.py'])] + input_api.PresubmitLocalPath.return_value = 'CWD' + input_api.os_walk.return_value = [('CWD', [], ['file1.py'])] process = mock.Mock() process.returncode = 0 @@ -2088,7 +2088,9 @@ the current line as well! pylint = os.path.join(_ROOT, 'pylint') pylintrc = os.path.join(_ROOT, 'pylintrc') - env = {'PYTHONPATH': ''} + env = {str('PYTHONPATH'): str('')} + if sys.platform == 'win32': + pylint += '.bat' results = presubmit_canned_checks.RunPylint( input_api, presubmit.OutputApi) @@ -2097,11 +2099,11 @@ the current line as well! self.assertEqual(subprocess.Popen.mock_calls, [ mock.call( [pylint, '--args-on-stdin'], env=env, - cwd='/foo', stderr=subprocess.STDOUT, stdout=subprocess.PIPE, + cwd='CWD', stderr=subprocess.STDOUT, stdout=subprocess.PIPE, stdin=subprocess.PIPE), mock.call( [pylint, '--args-on-stdin'], env=env, - cwd='/foo', stderr=subprocess.STDOUT, stdout=subprocess.PIPE, + cwd='CWD', stderr=subprocess.STDOUT, stdout=subprocess.PIPE, stdin=subprocess.PIPE), ]) self.assertEqual(presubmit.sigint_handler.wait.mock_calls, [