Show summary of violations (#1244)
- Show a summary of the of the number of violations. This can be disabled with the --no-summary option. - Return an error code if -verify flag not used and violation exists.
This commit is contained in:
parent
00970274b2
commit
e4f10bce6d
|
@ -23,9 +23,10 @@ import subprocess
|
||||||
ruleTexts = {}
|
ruleTexts = {}
|
||||||
|
|
||||||
VERIFY = False
|
VERIFY = False
|
||||||
|
SHOW_SUMMARY = True
|
||||||
VERIFY_EXPECTED = []
|
VERIFY_EXPECTED = []
|
||||||
VERIFY_ACTUAL = []
|
VERIFY_ACTUAL = []
|
||||||
|
VIOLATIONS = []
|
||||||
|
|
||||||
def reportError(location, num1, num2):
|
def reportError(location, num1, num2):
|
||||||
if VERIFY:
|
if VERIFY:
|
||||||
|
@ -39,8 +40,10 @@ def reportError(location, num1, num2):
|
||||||
errmsg = 'misra violation (use --rule-texts=<file> to get proper output) [' + id + ']'
|
errmsg = 'misra violation (use --rule-texts=<file> to get proper output) [' + id + ']'
|
||||||
else:
|
else:
|
||||||
return
|
return
|
||||||
sys.stderr.write('[' + location.file + ':' + str(location.linenr) + '] (style): ' + errmsg + '\n')
|
errmsg = '[' + location.file + ':' + str(location.linenr) + '] (style): ' + errmsg + '\n'
|
||||||
|
sys.stderr.write(errmsg)
|
||||||
|
|
||||||
|
VIOLATIONS.append(errmsg)
|
||||||
|
|
||||||
def simpleMatch(token, pattern):
|
def simpleMatch(token, pattern):
|
||||||
for p in pattern.split(' '):
|
for p in pattern.split(' '):
|
||||||
|
@ -1512,10 +1515,13 @@ for arg in sys.argv[1:]:
|
||||||
continue
|
continue
|
||||||
elif arg == "-generate-table":
|
elif arg == "-generate-table":
|
||||||
generateTable()
|
generateTable()
|
||||||
|
elif arg == "--no-summary":
|
||||||
|
SHOW_SUMMARY = False
|
||||||
else:
|
else:
|
||||||
print('Fatal error: unhandled argument ' + arg)
|
print('Fatal error: unhandled argument ' + arg)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
exitCode = 0
|
||||||
for arg in sys.argv[1:]:
|
for arg in sys.argv[1:]:
|
||||||
if not arg.endswith('.dump'):
|
if not arg.endswith('.dump'):
|
||||||
continue
|
continue
|
||||||
|
@ -1639,4 +1645,11 @@ for arg in sys.argv[1:]:
|
||||||
if actual not in VERIFY_EXPECTED:
|
if actual not in VERIFY_EXPECTED:
|
||||||
print('Not expected: ' + actual)
|
print('Not expected: ' + actual)
|
||||||
exitCode = 1
|
exitCode = 1
|
||||||
sys.exit(exitCode)
|
|
||||||
|
if not VERIFY:
|
||||||
|
if len(VIOLATIONS) > 0:
|
||||||
|
if SHOW_SUMMARY:
|
||||||
|
print("\nRule violations found: %d\n"%(len(VIOLATIONS)))
|
||||||
|
exitCode = 1
|
||||||
|
|
||||||
|
sys.exit(exitCode)
|
||||||
|
|
Loading…
Reference in New Issue