Commit 37e8e740 authored by dbeam's avatar dbeam Committed by Commit bot

Add presubmit warning about deprecated compiled_resources.gyp

Just use v2 instead ;) (compiled_resources2.gyp)

R=maruel@chromium.org,cpu@chromium.org
BUG=585553

Review URL: https://codereview.chromium.org/1686663002

Cr-Commit-Position: refs/heads/master@{#374762}
parent 2901378a
......@@ -1545,6 +1545,24 @@ def _CheckSingletonInHeaders(input_api, output_api):
return []
def _CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api):
"""Checks for old style compiled_resources.gyp files."""
is_compiled_resource = lambda fp: fp.endswith('compiled_resources.gyp')
added_compiled_resources = filter(is_compiled_resource, [
f.LocalPath() for f in input_api.AffectedFiles() if f.Action() == 'A'
])
if not added_compiled_resources:
return []
return [output_api.PresubmitError(
"Found new compiled_resources.gyp files:\n%s\n\n"
"compiled_resources.gyp files are deprecated,\n"
"please use compiled_resources2.gyp instead" %
"\n".join(added_compiled_resources))]
_DEPRECATED_CSS = [
# Values
( "-webkit-box", "flex" ),
......@@ -1676,6 +1694,7 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckForCopyrightedCode(input_api, output_api))
results.extend(_CheckForWindowsLineEndings(input_api, output_api))
results.extend(_CheckSingletonInHeaders(input_api, output_api))
results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api))
if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
......
......@@ -416,6 +416,20 @@ class CheckSingletonInHeadersTest(unittest.TestCase):
self.assertEqual(0, len(warnings))
class CheckNoDeprecatedCompiledResourcesGYPTest(unittest.TestCase):
def testNoDeprecatedCompiledResourcsGYP(self):
mock_input_api = MockInputApi()
mock_input_api.files = [MockFile('some/js/compiled_resources.gyp', [])]
errors = PRESUBMIT._CheckNoDeprecatedCompiledResourcesGYP(mock_input_api,
MockOutputApi())
self.assertEquals(1, len(errors))
mock_input_api.files = [MockFile('some/js/compiled_resources2.gyp', [])]
errors = PRESUBMIT._CheckNoDeprecatedCompiledResourcesGYP(mock_input_api,
MockOutputApi())
self.assertEquals(0, len(errors))
class InvalidOSMacroNamesTest(unittest.TestCase):
def testInvalidOSMacroNames(self):
lines = ['#if defined(OS_WINDOWS)',
......
......@@ -97,6 +97,9 @@ class MockFile(object):
self._new_contents = new_contents
self._changed_contents = [(i + 1, l) for i, l in enumerate(new_contents)]
def Action(self):
return 'A' # TODO(dbeam): feel free to change if your test actually uses.
def ChangedContents(self):
return self._changed_contents
......
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