diff options
author | dbeam <dbeam@chromium.org> | 2016-02-10 14:58:20 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-02-10 23:00:46 +0000 |
commit | 37e8e740cb9888582189876d07e0b4dbdc1cae37 (patch) | |
tree | 6c5772059e65c4b142b953422b2bfda04e66e8d5 | |
parent | 2901378a3c187dbe7ce9c4ac9a5201194d6e4e49 (diff) | |
download | chromium_src-37e8e740cb9888582189876d07e0b4dbdc1cae37.zip chromium_src-37e8e740cb9888582189876d07e0b4dbdc1cae37.tar.gz chromium_src-37e8e740cb9888582189876d07e0b4dbdc1cae37.tar.bz2 |
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}
-rw-r--r-- | PRESUBMIT.py | 19 | ||||
-rwxr-xr-x | PRESUBMIT_test.py | 14 | ||||
-rw-r--r-- | PRESUBMIT_test_mocks.py | 3 |
3 files changed, 36 insertions, 0 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py index f7d2047..e680575 100644 --- a/PRESUBMIT.py +++ b/PRESUBMIT.py @@ -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( diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py index 6b83350..90a8daf 100755 --- a/PRESUBMIT_test.py +++ b/PRESUBMIT_test.py @@ -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)', diff --git a/PRESUBMIT_test_mocks.py b/PRESUBMIT_test_mocks.py index 8e15d8c..f68c134 100644 --- a/PRESUBMIT_test_mocks.py +++ b/PRESUBMIT_test_mocks.py @@ -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 |