Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """Top-level presubmit script for Chromium. | 5 """Top-level presubmit script for Chromium. |
| 6 | 6 |
| 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts | 7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts |
| 8 for more details about the presubmit API built into gcl. | 8 for more details about the presubmit API built into gcl. |
| 9 """ | 9 """ |
| 10 | 10 |
| (...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1396 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) | 1396 source_file_filter=lambda x: x.LocalPath().endswith('.grd'))) |
| 1397 results.extend(_CheckSpamLogging(input_api, output_api)) | 1397 results.extend(_CheckSpamLogging(input_api, output_api)) |
| 1398 results.extend(_CheckForAnonymousVariables(input_api, output_api)) | 1398 results.extend(_CheckForAnonymousVariables(input_api, output_api)) |
| 1399 results.extend(_CheckCygwinShell(input_api, output_api)) | 1399 results.extend(_CheckCygwinShell(input_api, output_api)) |
| 1400 results.extend(_CheckUserActionUpdate(input_api, output_api)) | 1400 results.extend(_CheckUserActionUpdate(input_api, output_api)) |
| 1401 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) | 1401 results.extend(_CheckNoDeprecatedCSS(input_api, output_api)) |
| 1402 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) | 1402 results.extend(_CheckNoDeprecatedJS(input_api, output_api)) |
| 1403 results.extend(_CheckParseErrors(input_api, output_api)) | 1403 results.extend(_CheckParseErrors(input_api, output_api)) |
| 1404 results.extend(_CheckForIPCRules(input_api, output_api)) | 1404 results.extend(_CheckForIPCRules(input_api, output_api)) |
| 1405 results.extend(_CheckForCopyrightedCode(input_api, output_api)) | 1405 results.extend(_CheckForCopyrightedCode(input_api, output_api)) |
| 1406 results.extend(_CheckForWindowsLineEndings(input_api, output_api)) | |
| 1406 | 1407 |
| 1407 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): | 1408 if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): |
| 1408 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( | 1409 results.extend(input_api.canned_checks.RunUnitTestsInDirectory( |
| 1409 input_api, output_api, | 1410 input_api, output_api, |
| 1410 input_api.PresubmitLocalPath(), | 1411 input_api.PresubmitLocalPath(), |
| 1411 whitelist=[r'^PRESUBMIT_test\.py$'])) | 1412 whitelist=[r'^PRESUBMIT_test\.py$'])) |
| 1412 return results | 1413 return results |
| 1413 | 1414 |
| 1414 | 1415 |
| 1415 def _CheckAuthorizedAuthor(input_api, output_api): | 1416 def _CheckAuthorizedAuthor(input_api, output_api): |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1581 problems.append( | 1582 problems.append( |
| 1582 '%s:%d\n %s' % (local_path, line_number, line.strip())) | 1583 '%s:%d\n %s' % (local_path, line_number, line.strip())) |
| 1583 | 1584 |
| 1584 if problems: | 1585 if problems: |
| 1585 return [output_api.PresubmitPromptWarning( | 1586 return [output_api.PresubmitPromptWarning( |
| 1586 _IPC_ENUM_TRAITS_DEPRECATED, problems)] | 1587 _IPC_ENUM_TRAITS_DEPRECATED, problems)] |
| 1587 else: | 1588 else: |
| 1588 return [] | 1589 return [] |
| 1589 | 1590 |
| 1590 | 1591 |
| 1592 def _CheckForWindowsLineEndings(input_api, output_api): | |
| 1593 """Check source code and known ascii text files for windows style line | |
| 1594 endings. | |
| 1595 """ | |
| 1596 known_text_files = r'.*\.(txt|html|htm|mhtml|py)$' | |
| 1597 | |
| 1598 file_inclusion_pattern = ( | |
| 1599 known_text_files, | |
| 1600 r'.+%s' % _IMPLEMENTATION_EXTENSIONS | |
| 1601 ) | |
| 1602 | |
| 1603 filter = lambda f: input_api.FilterSourceFile( | |
| 1604 f, white_list=file_inclusion_pattern, black_list=None) | |
| 1605 files = [f.LocalPath() for f in | |
| 1606 input_api.AffectedSourceFiles(filter)] | |
| 1607 | |
| 1608 problems = [] | |
| 1609 | |
| 1610 for file in files: | |
| 1611 fp = open(file, 'r') | |
| 1612 for line in fp: | |
| 1613 if line.endswith('\r\n'): | |
| 1614 problems.append(file) | |
| 1615 break | |
| 1616 fp.close() | |
| 1617 | |
| 1618 if problems: | |
| 1619 return [output_api.PresubmitPromptWarning('Are you sure that you want ' | |
| 1620 'these files to contain windows style line endings?\n' + | |
|
tfarina
2014/12/22 12:13:57
s/windows/Windows?
Mostyn Bramley-Moore
2014/12/22 12:17:32
Done.
| |
| 1621 '\n'.join(problems))] | |
| 1622 | |
| 1623 return [] | |
| 1624 | |
| 1625 | |
| 1591 def CheckChangeOnUpload(input_api, output_api): | 1626 def CheckChangeOnUpload(input_api, output_api): |
| 1592 results = [] | 1627 results = [] |
| 1593 results.extend(_CommonChecks(input_api, output_api)) | 1628 results.extend(_CommonChecks(input_api, output_api)) |
| 1594 results.extend(_CheckValidHostsInDEPS(input_api, output_api)) | 1629 results.extend(_CheckValidHostsInDEPS(input_api, output_api)) |
| 1595 results.extend(_CheckJavaStyle(input_api, output_api)) | 1630 results.extend(_CheckJavaStyle(input_api, output_api)) |
| 1596 results.extend(_CheckUmaHistogramChanges(input_api, output_api)) | 1631 results.extend(_CheckUmaHistogramChanges(input_api, output_api)) |
| 1597 results.extend( | 1632 results.extend( |
| 1598 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) | 1633 input_api.canned_checks.CheckGNFormatted(input_api, output_api)) |
| 1599 return results | 1634 return results |
| 1600 | 1635 |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1812 ] | 1847 ] |
| 1813 | 1848 |
| 1814 # Match things like path/aura/file.cc and path/file_aura.cc. | 1849 # Match things like path/aura/file.cc and path/file_aura.cc. |
| 1815 # Same for chromeos. | 1850 # Same for chromeos. |
| 1816 if any(re.search(r'[\\\/_](aura|chromeos)', f) for f in files): | 1851 if any(re.search(r'[\\\/_](aura|chromeos)', f) for f in files): |
| 1817 builders.extend([ | 1852 builders.extend([ |
| 1818 'linux_chromeos_asan', | 1853 'linux_chromeos_asan', |
| 1819 ]) | 1854 ]) |
| 1820 | 1855 |
| 1821 return GetDefaultTryConfigs(builders) | 1856 return GetDefaultTryConfigs(builders) |
| OLD | NEW |