mirror of
https://xff.cz/git/u-boot/
synced 2025-09-25 20:41:16 +02:00
patman: Decode output from the '--show-types' option
Collect the 'checkpatch type' from each error, warning and check. Provide this to patman and update the uclass test to use it. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -38,7 +38,7 @@ def FindCheckPatch():
|
|||||||
sys.exit('Cannot find checkpatch.pl - please put it in your ' +
|
sys.exit('Cannot find checkpatch.pl - please put it in your ' +
|
||||||
'~/bin directory or use --no-check')
|
'~/bin directory or use --no-check')
|
||||||
|
|
||||||
def CheckPatch(fname, verbose=False):
|
def CheckPatch(fname, verbose=False, show_types=False):
|
||||||
"""Run checkpatch.pl on a file.
|
"""Run checkpatch.pl on a file.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
@@ -64,8 +64,10 @@ def CheckPatch(fname, verbose=False):
|
|||||||
result.problems = []
|
result.problems = []
|
||||||
chk = FindCheckPatch()
|
chk = FindCheckPatch()
|
||||||
item = {}
|
item = {}
|
||||||
result.stdout = command.Output(chk, '--no-tree', fname,
|
args = [chk, '--no-tree']
|
||||||
raise_on_error=False)
|
if show_types:
|
||||||
|
args.append('--show-types')
|
||||||
|
result.stdout = command.Output(*args, fname, raise_on_error=False)
|
||||||
#pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
#pipe = subprocess.Popen(cmd, stdout=subprocess.PIPE)
|
||||||
#stdout, stderr = pipe.communicate()
|
#stdout, stderr = pipe.communicate()
|
||||||
|
|
||||||
@@ -81,9 +83,10 @@ def CheckPatch(fname, verbose=False):
|
|||||||
' checks, (\d+)')
|
' checks, (\d+)')
|
||||||
re_ok = re.compile('.*has no obvious style problems')
|
re_ok = re.compile('.*has no obvious style problems')
|
||||||
re_bad = re.compile('.*has style problems, please review')
|
re_bad = re.compile('.*has style problems, please review')
|
||||||
re_error = re.compile('ERROR: (.*)')
|
type_name = '([A-Z_]+:)?'
|
||||||
re_warning = re.compile(emacs_prefix + 'WARNING:(?:[A-Z_]+:)? (.*)')
|
re_error = re.compile('ERROR:%s (.*)' % type_name)
|
||||||
re_check = re.compile('CHECK: (.*)')
|
re_warning = re.compile(emacs_prefix + 'WARNING:%s (.*)' % type_name)
|
||||||
|
re_check = re.compile('CHECK:%s (.*)' % type_name)
|
||||||
re_file = re.compile('#\d+: FILE: ([^:]*):(\d+):')
|
re_file = re.compile('#\d+: FILE: ([^:]*):(\d+):')
|
||||||
re_note = re.compile('NOTE: (.*)')
|
re_note = re.compile('NOTE: (.*)')
|
||||||
indent = ' ' * 6
|
indent = ' ' * 6
|
||||||
@@ -129,13 +132,16 @@ def CheckPatch(fname, verbose=False):
|
|||||||
check_match = re_check.match(line)
|
check_match = re_check.match(line)
|
||||||
subject_match = line.startswith('Subject:')
|
subject_match = line.startswith('Subject:')
|
||||||
if err_match:
|
if err_match:
|
||||||
item['msg'] = err_match.group(1)
|
item['cptype'] = err_match.group(1)
|
||||||
|
item['msg'] = err_match.group(2)
|
||||||
item['type'] = 'error'
|
item['type'] = 'error'
|
||||||
elif warn_match:
|
elif warn_match:
|
||||||
item['msg'] = warn_match.group(1)
|
item['cptype'] = warn_match.group(1)
|
||||||
|
item['msg'] = warn_match.group(2)
|
||||||
item['type'] = 'warning'
|
item['type'] = 'warning'
|
||||||
elif check_match:
|
elif check_match:
|
||||||
item['msg'] = check_match.group(1)
|
item['cptype'] = check_match.group(1)
|
||||||
|
item['msg'] = check_match.group(2)
|
||||||
item['type'] = 'check'
|
item['type'] = 'check'
|
||||||
elif file_match:
|
elif file_match:
|
||||||
item['file'] = file_match.group(1)
|
item['file'] = file_match.group(1)
|
||||||
|
@@ -82,7 +82,7 @@ Signed-off-by: Simon Glass <sjg@chromium.org>
|
|||||||
return inname
|
return inname
|
||||||
|
|
||||||
def run_checkpatch(self):
|
def run_checkpatch(self):
|
||||||
return checkpatch.CheckPatch(self.get_patch())
|
return checkpatch.CheckPatch(self.get_patch(), show_types=True)
|
||||||
|
|
||||||
|
|
||||||
class TestPatch(unittest.TestCase):
|
class TestPatch(unittest.TestCase):
|
||||||
@@ -355,7 +355,7 @@ index 0000000..2234c87
|
|||||||
result = pm.run_checkpatch()
|
result = pm.run_checkpatch()
|
||||||
self.assertEqual(result.warnings, 1)
|
self.assertEqual(result.warnings, 1)
|
||||||
self.assertEqual(len(result.problems), 1)
|
self.assertEqual(len(result.problems), 1)
|
||||||
self.assertIn('Possible new uclass', result.problems[0]['msg'])
|
self.assertIn('NEW_UCLASS', result.problems[0]['cptype'])
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
Reference in New Issue
Block a user