Fix some issues in PRESUBMIT script
When I read the Chromium source, I first noticed that some python files for presubmit located in the root directory had some problems (like incorrect function names, indentation, typos, etc.), so I tried to fix them. BUG=nobug Change-Id: I3646b9fc1761d3cd2af884aba8d815d09665e7be Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3812981 Reviewed-by: Erik Staab <estaab@chromium.org> Commit-Queue: Erik Staab <estaab@chromium.org> Cr-Commit-Position: refs/heads/main@{#1032601}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
e4c2e78821
commit
a79ebd4d91
1
AUTHORS
1
AUTHORS
@ -385,6 +385,7 @@ Gajendra Singh <wxjg68@motorola.com>
|
||||
Ganesh Borle <ganesh.borle@samsung.com>
|
||||
Gao Chun <chun.gao@intel.com>
|
||||
Gao Chun <gaochun.dev@gmail.com>
|
||||
Gao Sheng <gaosheng08@meituan.com>
|
||||
Gao Yu <wanggao@tencent.com>
|
||||
Gaurav Dhol <gaurav.dhol@einfochips.com>
|
||||
Gautham Banasandra <gautham.bangalore@gmail.com>
|
||||
|
10
PRESUBMIT.py
10
PRESUBMIT.py
@ -3771,7 +3771,7 @@ class PydepsChecker:
|
||||
return self._file_cache[path]
|
||||
|
||||
def _ComputeNormalizedPydepsEntries(self, pydeps_path):
|
||||
"""Returns an interable of paths within the .pydep, relativized to //."""
|
||||
"""Returns an iterable of paths within the .pydep, relativized to //."""
|
||||
pydeps_data = self._LoadFile(pydeps_path)
|
||||
uses_gn_paths = '--gn-paths' in pydeps_data
|
||||
entries = (l for l in pydeps_data.splitlines()
|
||||
@ -3898,7 +3898,7 @@ def CheckPydepsNeedsUpdating(input_api, output_api, checker_for_tests=None):
|
||||
results.append(
|
||||
output_api.PresubmitPromptOrNotify(
|
||||
'You have changed python files that may affect pydeps for android\n'
|
||||
'specific scripts. However, the relevant presumbit check cannot be\n'
|
||||
'specific scripts. However, the relevant presubmit check cannot be\n'
|
||||
'run because you are not using an Android checkout. To validate that\n'
|
||||
'the .pydeps are correct, re-run presubmit in an Android checkout, or\n'
|
||||
'use the android-internal-presubmit optional trybot.\n'
|
||||
@ -4245,7 +4245,7 @@ def CheckGnGlobForward(input_api, output_api):
|
||||
'forward_variables_from("*") without exclusions',
|
||||
items=sorted(problems),
|
||||
long_text=(
|
||||
'The variables "visibilty" and "test_only" should be '
|
||||
'The variables "visibility" and "test_only" should be '
|
||||
'explicitly listed in forward_variables_from(). For more '
|
||||
'details, see:\n'
|
||||
'https://chromium.googlesource.com/chromium/src/+/HEAD/'
|
||||
@ -5217,7 +5217,7 @@ def CheckForUseOfChromeAppsDeprecations(input_api, output_api):
|
||||
detection_list=['config=nacl', 'enable-nacl', 'cpu=pnacl', 'nacl_io'],
|
||||
files_to_skip=files_to_skip + [r"^native_client_sdk[\\/]"])
|
||||
|
||||
# PPAPI: any C/C++ file that in its diff includes a ppappi library
|
||||
# PPAPI: any C/C++ file that in its diff includes a ppapi library
|
||||
problems += _CheckForDeprecatedTech(
|
||||
input_api,
|
||||
output_api,
|
||||
@ -5675,7 +5675,7 @@ def CheckTranslationExpectations(input_api, output_api,
|
||||
grd_files = git_helper.list_grds_in_repository(repo_root)
|
||||
|
||||
# Ignore bogus grd files used only for testing
|
||||
# ui/webui/resoucres/tools/generate_grd.py.
|
||||
# ui/webui/resources/tools/generate_grd.py.
|
||||
ignore_path = input_api.os_path.join('ui', 'webui', 'resources', 'tools',
|
||||
'tests')
|
||||
grd_files = [p for p in grd_files if ignore_path not in p]
|
||||
|
@ -935,7 +935,7 @@ class AccessibilityRelnotesFieldTest(unittest.TestCase):
|
||||
|
||||
# The relnotes footer is not required for changes which do not touch any
|
||||
# accessibility directories.
|
||||
def testIgnoresNonAccesssibilityCode(self):
|
||||
def testIgnoresNonAccessibilityCode(self):
|
||||
mock_input_api = MockInputApi()
|
||||
mock_output_api = MockOutputApi()
|
||||
|
||||
@ -1031,7 +1031,7 @@ class AccessibilityRelnotesFieldTest(unittest.TestCase):
|
||||
MockAffectedFile('ui/accessibility/foo.bar', ['']),
|
||||
]
|
||||
mock_input_api.change.DescriptionText = lambda : ('Description:\n' +
|
||||
'ax-relnotes= this is a valid format for accessibiliy relnotes')
|
||||
'ax-relnotes= this is a valid format for accessibility relnotes')
|
||||
|
||||
msgs = PRESUBMIT.CheckAccessibilityRelnotesField(
|
||||
mock_input_api, mock_output_api)
|
||||
@ -1643,13 +1643,13 @@ class LogUsageTest(unittest.TestCase):
|
||||
MockAffectedFile('HasTooLongTag.java', [
|
||||
'import org.chromium.base.Log;',
|
||||
'some random stuff',
|
||||
'private static final String TAG = "21_charachers_long___";',
|
||||
'private static final String TAG = "21_characters_long___";',
|
||||
'Log.d(TAG, "foo");',
|
||||
]),
|
||||
MockAffectedFile('HasTooLongTagWithNoLogCallsInDiff.java', [
|
||||
'import org.chromium.base.Log;',
|
||||
'some random stuff',
|
||||
'private static final String TAG = "21_charachers_long___";',
|
||||
'private static final String TAG = "21_characters_long___";',
|
||||
]),
|
||||
]
|
||||
|
||||
@ -2440,7 +2440,7 @@ class IpcSecurityOwnerTest(_SecurityOwnersTestCase):
|
||||
'Review from an owner in ipc/SECURITY_OWNERS is required for the '
|
||||
'following newly-added files:', results[0].message)
|
||||
|
||||
def testmissingSecurityApprovalAtRealCommit(self):
|
||||
def testMissingSecurityApprovalAtRealCommit(self):
|
||||
mock_input_api = self._createMockInputApi()
|
||||
new_owners_file_path = mock_input_api.os_path.join(
|
||||
'services', 'goat', 'public', 'OWNERS')
|
||||
@ -3309,8 +3309,7 @@ class StringTest(unittest.TestCase):
|
||||
self.NEW_GRD_CONTENTS1, action='M'),
|
||||
MockAffectedFile('part.grdp', self.NEW_GRDP_CONTENTS1,
|
||||
self.NEW_GRDP_CONTENTS1, action='M')])
|
||||
warnings = PRESUBMIT.CheckStrings(input_api,
|
||||
MockOutputApi())
|
||||
warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
|
||||
self.assertEqual(0, len(warnings))
|
||||
|
||||
# Add two new strings. Should have two warnings.
|
||||
@ -3319,8 +3318,7 @@ class StringTest(unittest.TestCase):
|
||||
self.NEW_GRD_CONTENTS1, action='M'),
|
||||
MockAffectedFile('part.grdp', self.NEW_GRDP_CONTENTS2,
|
||||
self.NEW_GRDP_CONTENTS1, action='M')])
|
||||
warnings = PRESUBMIT.CheckStrings(input_api,
|
||||
MockOutputApi())
|
||||
warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(warnings))
|
||||
self.assertEqual(self.GENERATE_SIGNATURES_MESSAGE, warnings[0].message)
|
||||
self.assertEqual('error', warnings[0].type)
|
||||
@ -3335,8 +3333,7 @@ class StringTest(unittest.TestCase):
|
||||
self.OLD_GRD_CONTENTS, action='M'),
|
||||
MockAffectedFile('part.grdp', self.NEW_GRDP_CONTENTS2,
|
||||
self.OLD_GRDP_CONTENTS, action='M')])
|
||||
warnings = PRESUBMIT.CheckStrings(input_api,
|
||||
MockOutputApi())
|
||||
warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(warnings))
|
||||
self.assertEqual('error', warnings[0].type)
|
||||
self.assertEqual(self.GENERATE_SIGNATURES_MESSAGE, warnings[0].message)
|
||||
@ -3401,8 +3398,7 @@ class StringTest(unittest.TestCase):
|
||||
MockAffectedFile(
|
||||
os.path.join('test_grd', 'IDS_TEST1.png'), 'binary', action='A')
|
||||
])
|
||||
warnings = PRESUBMIT.CheckStrings(input_api,
|
||||
MockOutputApi())
|
||||
warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
|
||||
self.assertEqual(2, len(warnings))
|
||||
self.assertEqual('error', warnings[0].type)
|
||||
self.assertEqual(self.DO_NOT_UPLOAD_PNG_MESSAGE, warnings[0].message)
|
||||
@ -3438,8 +3434,7 @@ class StringTest(unittest.TestCase):
|
||||
os.path.join('part_grdp', 'IDS_PART_TEST1.png'), 'binary',
|
||||
action='A')
|
||||
])
|
||||
warnings = PRESUBMIT.CheckStrings(input_api,
|
||||
MockOutputApi())
|
||||
warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
|
||||
self.assertEqual(2, len(warnings))
|
||||
self.assertEqual('error', warnings[0].type)
|
||||
self.assertEqual(self.DO_NOT_UPLOAD_PNG_MESSAGE, warnings[0].message)
|
||||
@ -3485,8 +3480,7 @@ class StringTest(unittest.TestCase):
|
||||
'binary',
|
||||
action='A'),
|
||||
])
|
||||
warnings = PRESUBMIT.CheckStrings(input_api,
|
||||
MockOutputApi())
|
||||
warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
|
||||
self.assertEqual([], warnings)
|
||||
|
||||
def testScreenshotsRemovedWithSha1(self):
|
||||
@ -3513,8 +3507,7 @@ class StringTest(unittest.TestCase):
|
||||
MockFile(os.path.join('part_grdp', 'IDS_PART_TEST2.png.sha1'),
|
||||
'binary', '')
|
||||
])
|
||||
warnings = PRESUBMIT.CheckStrings(input_api,
|
||||
MockOutputApi())
|
||||
warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(warnings))
|
||||
self.assertEqual('error', warnings[0].type)
|
||||
self.assertEqual(self.REMOVE_SIGNATURES_MESSAGE, warnings[0].message)
|
||||
@ -3554,8 +3547,7 @@ class StringTest(unittest.TestCase):
|
||||
'old_contents',
|
||||
action='D')
|
||||
])
|
||||
warnings = PRESUBMIT.CheckStrings(input_api,
|
||||
MockOutputApi())
|
||||
warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
|
||||
self.assertEqual(1, len(warnings))
|
||||
self.assertEqual('error', warnings[0].type)
|
||||
self.assertEqual(self.REMOVE_SIGNATURES_MESSAGE, warnings[0].message)
|
||||
@ -3594,8 +3586,7 @@ class StringTest(unittest.TestCase):
|
||||
'binary',
|
||||
action='D')
|
||||
])
|
||||
warnings = PRESUBMIT.CheckStrings(input_api,
|
||||
MockOutputApi())
|
||||
warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
|
||||
self.assertEqual([], warnings)
|
||||
|
||||
def testIcuSyntax(self):
|
||||
@ -3831,7 +3822,7 @@ class DISABLETypoInTest(unittest.TestCase):
|
||||
msg=('expected foo_unittest.cc in message but got %s in test %s' %
|
||||
(results[0].message, test)))
|
||||
|
||||
def testIngoreNotTestFiles(self):
|
||||
def testIgnoreNotTestFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
mock_input_api.files = [
|
||||
MockFile('some/path/foo.cc', 'TEST_F(FoobarTest, DISABLE_Foo)'),
|
||||
@ -3841,7 +3832,7 @@ class DISABLETypoInTest(unittest.TestCase):
|
||||
MockOutputApi())
|
||||
self.assertEqual(0, len(results))
|
||||
|
||||
def testIngoreDeletedFiles(self):
|
||||
def testIgnoreDeletedFiles(self):
|
||||
mock_input_api = MockInputApi()
|
||||
mock_input_api.files = [
|
||||
MockFile('some/path/foo.cc', 'TEST_F(FoobarTest, Foo)', action='D'),
|
||||
@ -4092,7 +4083,7 @@ class CheckForUseOfChromeAppsDeprecationsTest(unittest.TestCase):
|
||||
]
|
||||
mock_output_api = MockOutputApi()
|
||||
errors = PRESUBMIT.CheckForUseOfChromeAppsDeprecations(mock_input_api,
|
||||
mock_output_api)
|
||||
mock_output_api)
|
||||
self.assertEqual(1, len(errors))
|
||||
self.assertTrue( self.ERROR_MSG_PIECE in errors[0].message)
|
||||
self.assertTrue( 'foo.NMF' in errors[0].message)
|
||||
@ -4115,7 +4106,7 @@ class CheckForUseOfChromeAppsDeprecationsTest(unittest.TestCase):
|
||||
]
|
||||
mock_output_api = MockOutputApi()
|
||||
errors = PRESUBMIT.CheckForUseOfChromeAppsDeprecations(mock_input_api,
|
||||
mock_output_api)
|
||||
mock_output_api)
|
||||
self.assertEqual(1, len(errors))
|
||||
self.assertTrue( self.ERROR_MSG_PIECE in errors[0].message)
|
||||
self.assertTrue( 'manifest.json' in errors[0].message)
|
||||
@ -4138,7 +4129,7 @@ class CheckForUseOfChromeAppsDeprecationsTest(unittest.TestCase):
|
||||
]
|
||||
mock_output_api = MockOutputApi()
|
||||
errors = PRESUBMIT.CheckForUseOfChromeAppsDeprecations(mock_input_api,
|
||||
mock_output_api)
|
||||
mock_output_api)
|
||||
self.assertEqual(0, len(errors))
|
||||
|
||||
def testWarningPPAPI(self):
|
||||
@ -4159,7 +4150,7 @@ class CheckForUseOfChromeAppsDeprecationsTest(unittest.TestCase):
|
||||
]
|
||||
mock_output_api = MockOutputApi()
|
||||
errors = PRESUBMIT.CheckForUseOfChromeAppsDeprecations(mock_input_api,
|
||||
mock_output_api)
|
||||
mock_output_api)
|
||||
self.assertEqual(1, len(errors))
|
||||
self.assertTrue( self.ERROR_MSG_PIECE in errors[0].message)
|
||||
self.assertTrue( 'foo.hpp' in errors[0].message)
|
||||
@ -4182,7 +4173,7 @@ class CheckForUseOfChromeAppsDeprecationsTest(unittest.TestCase):
|
||||
]
|
||||
mock_output_api = MockOutputApi()
|
||||
errors = PRESUBMIT.CheckForUseOfChromeAppsDeprecations(mock_input_api,
|
||||
mock_output_api)
|
||||
mock_output_api)
|
||||
self.assertEqual(0, len(errors))
|
||||
|
||||
class CheckDeprecationOfPreferencesTest(unittest.TestCase):
|
||||
@ -4313,7 +4304,7 @@ class CheckDeprecationOfPreferencesTest(unittest.TestCase):
|
||||
'Discovered possible removal of preference registrations' in
|
||||
errors[0].message)
|
||||
|
||||
# Check that the presubmit fails if a marker line in brower_prefs.cc is
|
||||
# Check that the presubmit fails if a marker line in browser_prefs.cc is
|
||||
# deleted.
|
||||
def testDeletedMarkerRaisesError(self):
|
||||
mock_input_api = MockInputApi()
|
||||
|
@ -142,7 +142,7 @@ class MockInputApi(object):
|
||||
class MockOutputApi(object):
|
||||
"""Mock class for the OutputApi class.
|
||||
|
||||
An instance of this class can be passed to presubmit unittests for outputing
|
||||
An instance of this class can be passed to presubmit unittests for outputting
|
||||
various types of results.
|
||||
"""
|
||||
|
||||
|
Reference in New Issue
Block a user