Commit 2cf14c73 authored by Kent Tamura's avatar Kent Tamura Committed by Commit Bot

Remove third_party/WebKit/PRESUBMIT*.py

PRESUBMIT.py existed just for linting LayoutTest/TestExpectations.
It's unnecessary now.

No-Try: true
Bug: 622551
Change-Id: I4e3d801ecfa829f3a99e187eb2058fa326aa7c67
Reviewed-on: https://chromium-review.googlesource.com/c/1350430
Commit-Queue: Kent Tamura <tkent@chromium.org>
Reviewed-by: default avatarQuinten Yearsley <qyearsley@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611016}
parent d4d9ad55
# Copyright (c) 2013 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Top-level presubmit script for Blink.
See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into gcl.
"""
import os
def _CommonChecks(input_api, output_api):
"""Checks common to both upload and commit."""
# We should figure out what license checks we actually want to use.
license_header = r'.*'
results = []
results.extend(input_api.canned_checks.PanProjectChecks(
input_api, output_api, maxlen=800, license_header=license_header))
return results
def _CheckStyle(input_api, output_api):
style_checker_path = input_api.os_path.join(input_api.PresubmitLocalPath(), '..', 'blink',
'tools', 'check_blink_style.py')
args = [input_api.python_executable, style_checker_path, '--diff-files']
files = []
for f in input_api.AffectedFiles():
file_path = f.LocalPath()
# Filter out changes in LayoutTests.
if 'LayoutTests' + input_api.os_path.sep in file_path and 'TestExpectations' not in file_path:
continue
files.append(input_api.os_path.join('..', '..', file_path))
# Do not call check_blink_style.py with empty affected file list if all
# input_api.AffectedFiles got filtered.
if not files:
return []
args += files
results = []
try:
child = input_api.subprocess.Popen(args,
stderr=input_api.subprocess.PIPE)
_, stderrdata = child.communicate()
if child.returncode != 0:
results.append(output_api.PresubmitError(
'check_blink_style.py failed', [stderrdata]))
except Exception as e:
results.append(output_api.PresubmitNotifyResult(
'Could not run check_blink_style.py', [str(e)]))
return results
def CheckChangeOnUpload(input_api, output_api):
results = []
results.extend(_CommonChecks(input_api, output_api))
results.extend(_CheckStyle(input_api, output_api))
return results
def CheckChangeOnCommit(input_api, output_api):
results = []
results.extend(_CommonChecks(input_api, output_api))
results.extend(input_api.canned_checks.CheckTreeIsOpen(
input_api, output_api,
json_url='http://chromium-status.appspot.com/current?format=json'))
results.extend(input_api.canned_checks.CheckChangeHasDescription(
input_api, output_api))
return results
#!/usr/bin/env python
# Copyright 2017 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Note: running this test requires installing the package python-mock.
# pylint: disable=C0103
# pylint: disable=F0401
import PRESUBMIT
import os.path
import subprocess
import sys
import unittest
sys.path.append(
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'pymock'))
sys.path.append(
os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..'))
import mock
from PRESUBMIT_test_mocks import MockInputApi
from PRESUBMIT_test_mocks import MockOutputApi
from PRESUBMIT_test_mocks import MockAffectedFile
class Capture(object):
"""Class to capture a call argument that can be tested later on."""
def __init__(self):
self.value = None
def __eq__(self, other):
self.value = other
return True
class PresubmitTest(unittest.TestCase):
@mock.patch('subprocess.Popen')
def testCheckChangeOnUploadWithWebKitAndChromiumFiles(self, _):
"""This verifies that CheckChangeOnUpload will only call check_blink_style.py
on WebKit files.
"""
diff_file_webkit_h = ['some diff']
diff_file_chromium_h = ['another diff']
diff_file_test_expectations = ['more diff']
mock_input_api = MockInputApi()
mock_input_api.files = [
MockAffectedFile('FileWebkit.h', diff_file_webkit_h),
MockAffectedFile('file_chromium.h', diff_file_chromium_h),
MockAffectedFile('LayoutTests/TestExpectations', diff_file_test_expectations)
]
# Access to a protected member _CheckStyle
# pylint: disable=W0212
PRESUBMIT._CheckStyle(mock_input_api, MockOutputApi())
capture = Capture()
# pylint: disable=E1101
subprocess.Popen.assert_called_with(capture, stderr=-1)
self.assertEqual(6, len(capture.value))
self.assertEqual('../../FileWebkit.h', capture.value[3])
self.assertEqual('../../LayoutTests/TestExpectations', capture.value[5])
@mock.patch('subprocess.Popen')
def testCheckChangeOnUploadWithEmptyAffectedFileList(self, _):
"""This verifies that CheckChangeOnUpload will skip calling
check_blink_style.py if the affected file list is empty.
"""
diff_file_layout_test_html = ['more diff']
mock_input_api = MockInputApi()
mock_input_api.files = [
MockAffectedFile('LayoutTests/some_tests.html', diff_file_layout_test_html)
]
# Access to a protected member _CheckStyle
# pylint: disable=W0212
PRESUBMIT._CheckStyle(mock_input_api, MockOutputApi())
# pylint: disable=E1101
subprocess.Popen.assert_not_called()
if __name__ == '__main__':
unittest.main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment