Commit 53a58ad0 authored by Karandeep Bhatia's avatar Karandeep Bhatia Committed by Commit Bot

Docserver: Remove unnecessary presubmit tests.

Docserver related python tests were moved to the CQ in
crrev.com/c/2311823. Hence they don't need to be run as PRESUBMITs now.

BUG= 1105728, 619528

Change-Id: I0376f788327aa8152d1e76ee14e86452a38ed252
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347377
Commit-Queue: Karan Bhatia <karandeepb@chromium.org>
Reviewed-by: default avatarDevlin <rdevlin.cronin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#801188}
parent 1614e0dc
......@@ -13,78 +13,16 @@ import re
EXTENSIONS_PATH = os.path.join('chrome', 'common', 'extensions')
DOCS_PATH = os.path.join(EXTENSIONS_PATH, 'docs')
SERVER2_PATH = os.path.join(DOCS_PATH, 'server2')
API_PATH = os.path.join(EXTENSIONS_PATH, 'api')
TEMPLATES_PATH = os.path.join(DOCS_PATH, 'templates')
PRIVATE_TEMPLATES_PATH = os.path.join(TEMPLATES_PATH, 'private')
PUBLIC_TEMPLATES_PATH = os.path.join(TEMPLATES_PATH, 'public')
INTROS_PATH = os.path.join(TEMPLATES_PATH, 'intros')
ARTICLES_PATH = os.path.join(TEMPLATES_PATH, 'articles')
LOCAL_PUBLIC_TEMPLATES_PATH = os.path.join('docs',
'templates',
'public')
EXTENSIONS_TO_REMOVE_FOR_CLEAN_URLS = ('.md', '.html')
def _ReadFile(filename):
with open(filename) as f:
return f.read()
def _ListFilesInPublic():
all_files = []
for path, dirs, files in os.walk(LOCAL_PUBLIC_TEMPLATES_PATH):
all_files.extend(
os.path.join(path, filename)[len(LOCAL_PUBLIC_TEMPLATES_PATH + os.sep):]
for filename in files)
return all_files
def _UnixName(name):
name = os.path.splitext(name)[0]
s1 = re.sub('([a-z])([A-Z])', r'\1_\2', name)
s2 = re.sub('([A-Z]+)([A-Z][a-z])', r'\1_\2', s1)
return s2.replace('.', '_').lower()
def _FindMatchingTemplates(template_name, template_path_list):
matches = []
unix_name = _UnixName(template_name)
for template in template_path_list:
if unix_name == _UnixName(template.split(os.sep)[-1]):
basename, ext = os.path.splitext(template)
# The docserver expects clean (extensionless) template URLs, so we
# strip some extensions here when generating the list of matches.
if ext in EXTENSIONS_TO_REMOVE_FOR_CLEAN_URLS:
matches.append(basename)
else:
matches.append(template)
return matches
def _SanitizeAPIName(name, api_path):
if not api_path.endswith(os.sep):
api_path += os.sep
filename = os.path.splitext(name)[0][len(api_path):].replace(os.sep, '_')
if 'experimental' in filename:
filename = 'experimental_' + filename.replace('experimental_', '')
return filename
def _CreateIntegrationTestArgs(affected_files):
if (any(fnmatch.fnmatch(name, '%s*.py' % SERVER2_PATH)
for name in affected_files) or
any(fnmatch.fnmatch(name, '%s*' % PRIVATE_TEMPLATES_PATH)
for name in affected_files)):
return ['-a']
args = []
for name in affected_files:
if (fnmatch.fnmatch(name, '%s*' % PUBLIC_TEMPLATES_PATH) or
fnmatch.fnmatch(name, '%s*' % INTROS_PATH) or
fnmatch.fnmatch(name, '%s*' % ARTICLES_PATH)):
args.extend(_FindMatchingTemplates(name.split(os.sep)[-1],
_ListFilesInPublic()))
if fnmatch.fnmatch(name, '%s*' % API_PATH):
args.extend(_FindMatchingTemplates(_SanitizeAPIName(name, API_PATH),
_ListFilesInPublic()))
return args
def _CheckHeadingIDs(input_api):
ids_re = re.compile('<h[23].*id=.*?>')
headings_re = re.compile('<h[23].*?>')
......@@ -140,18 +78,6 @@ def _CheckChange(input_api, output_api):
results = [
output_api.PresubmitError('File %s needs an id for each heading.' % name)
for name in _CheckHeadingIDs(input_api)]
try:
integration_test = []
# From depot_tools/presubmit_canned_checks.py:529
if input_api.platform == 'win32':
integration_test = [input_api.python_executable]
integration_test.append(
os.path.join('docs', 'server2', 'integration_test.py'))
integration_test.extend(_CreateIntegrationTestArgs(input_api.LocalPaths()))
input_api.subprocess.check_call(integration_test,
cwd=input_api.PresubmitLocalPath())
except input_api.subprocess.CalledProcessError:
results.append(output_api.PresubmitError('IntegrationTest failed!'))
# TODO(kalman): Re-enable this check, or decide to delete it forever. Now
# that we have multiple directories it no longer works.
......
#!/usr/bin/env python
# Copyright (c) 2012 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.
import os
import unittest
import PRESUBMIT
EXTENSIONS_PATH = os.path.join('chrome', 'common', 'extensions')
DOCS_PATH = os.path.join(EXTENSIONS_PATH, 'docs')
SERVER2_PATH = os.path.join(DOCS_PATH, 'server2')
PUBLIC_PATH = os.path.join(DOCS_PATH, 'templates', 'public')
PRIVATE_PATH = os.path.join(DOCS_PATH, 'templates', 'private')
INTROS_PATH = os.path.join(DOCS_PATH, 'templates', 'intros')
ARTICLES_PATH = os.path.join(DOCS_PATH, 'templates', 'articles')
class PRESUBMITTest(unittest.TestCase):
def testCreateIntegrationTestArgs(self):
input_files = [
os.path.join(EXTENSIONS_PATH, 'test.cc'),
os.path.join(EXTENSIONS_PATH, 'test2.cc'),
os.path.join('test', 'test.py')
]
expected_files = []
self.assertEqual(expected_files,
PRESUBMIT._CreateIntegrationTestArgs(input_files))
expected_files.append(os.path.join('apps', 'fileSystem.html'))
input_files.append(os.path.join(EXTENSIONS_PATH, 'api', 'file_system.idl'))
self.assertEqual(expected_files,
PRESUBMIT._CreateIntegrationTestArgs(input_files))
expected_files.append(os.path.join('extensions', 'alarms.html'))
expected_files.append(os.path.join('apps', 'alarms.html'))
input_files.append(os.path.join(EXTENSIONS_PATH, 'api', 'alarms.json'))
self.assertEqual(expected_files,
PRESUBMIT._CreateIntegrationTestArgs(input_files))
expected_files.append('extensions/devtools_network.html')
input_files.append(os.path.join(EXTENSIONS_PATH,
'api',
'devtools',
'network.json'))
self.assertEqual(expected_files,
PRESUBMIT._CreateIntegrationTestArgs(input_files))
expected_files.append(os.path.join('extensions', 'docs.html'))
expected_files.append(os.path.join('apps', 'docs.html'))
input_files.append(os.path.join(PUBLIC_PATH, 'extensions', 'docs.html'))
self.assertEqual(expected_files,
PRESUBMIT._CreateIntegrationTestArgs(input_files))
expected_files.append(os.path.join('extensions', 'bookmarks.html'))
input_files.append(os.path.join(INTROS_PATH, 'bookmarks.html'))
self.assertEqual(expected_files,
PRESUBMIT._CreateIntegrationTestArgs(input_files))
expected_files.append(os.path.join('extensions', 'i18n.html'))
expected_files.append(os.path.join('apps', 'i18n.html'))
input_files.append(os.path.join(INTROS_PATH, 'i18n.html'))
self.assertEqual(expected_files,
PRESUBMIT._CreateIntegrationTestArgs(input_files))
expected_files.append(os.path.join('apps', 'about_apps.html'))
input_files.append(os.path.join(ARTICLES_PATH, 'about_apps.html'))
self.assertEqual(expected_files,
PRESUBMIT._CreateIntegrationTestArgs(input_files))
input_files.append(os.path.join(PRIVATE_PATH, 'type.html'))
self.assertEqual([ '-a' ],
PRESUBMIT._CreateIntegrationTestArgs(input_files))
input_files.pop()
input_files.append(os.path.join(SERVER2_PATH, 'test.txt'))
self.assertEqual(expected_files,
PRESUBMIT._CreateIntegrationTestArgs(input_files))
input_files.append(os.path.join(SERVER2_PATH, 'handler.py'))
self.assertEqual([ '-a' ],
PRESUBMIT._CreateIntegrationTestArgs(input_files))
if __name__ == '__main__':
unittest.main()
......@@ -8,23 +8,7 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
for more details about the presubmit API built into depot_tools.
"""
# Run build_server so that files needed by tests are copied to the local
# third_party directory.
import os
import sys
WHITELIST = [ r'.+_test.py$' ]
# The integration tests are selectively run from the PRESUBMIT in
# chrome/common/extensions.
BLACKLIST = [ r'integration_test.py$' ]
def _BuildServer(input_api):
try:
sys.path.insert(0, input_api.PresubmitLocalPath())
import build_server
build_server.main()
finally:
sys.path.pop(0)
def _WarnIfAppYamlHasntChanged(input_api, output_api):
app_yaml_path = os.path.join(input_api.PresubmitLocalPath(), 'app.yaml')
......@@ -56,13 +40,8 @@ No? I guess this presubmit check doesn't work.
''')]
def _RunPresubmit(input_api, output_api):
_BuildServer(input_api)
# TODO(crbug.com/434363): Enable pylint for the docserver.
return (
_WarnIfAppYamlHasntChanged(input_api, output_api) +
input_api.canned_checks.RunUnitTestsInDirectory(
input_api, output_api, '.', whitelist=WHITELIST, blacklist=BLACKLIST)
)
return _WarnIfAppYamlHasntChanged(input_api, output_api)
def CheckChangeOnUpload(input_api, output_api):
return _RunPresubmit(input_api, output_api)
......
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