Fixed #9830 (Addons should return 0 when success)
This commit is contained in:
parent
acd1e848dd
commit
c6d2e0fae1
|
@ -439,3 +439,5 @@ if __name__ == '__main__':
|
||||||
if actual not in VERIFY_EXPECTED:
|
if actual not in VERIFY_EXPECTED:
|
||||||
print('Not expected: ' + actual)
|
print('Not expected: ' + actual)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
sys.exit(cppcheckdata.EXIT_CODE)
|
||||||
|
|
|
@ -13,6 +13,8 @@ import sys
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
from fnmatch import fnmatch
|
from fnmatch import fnmatch
|
||||||
|
|
||||||
|
EXIT_CODE = 0
|
||||||
|
|
||||||
class Directive:
|
class Directive:
|
||||||
"""
|
"""
|
||||||
Directive class. Contains information about each preprocessor directive in the source code.
|
Directive class. Contains information about each preprocessor directive in the source code.
|
||||||
|
@ -1102,3 +1104,5 @@ def reportError(location, severity, message, addon, errorId, extra=''):
|
||||||
if len(extra) > 0:
|
if len(extra) > 0:
|
||||||
message += ' (' + extra + ')'
|
message += ' (' + extra + ')'
|
||||||
sys.stderr.write('%s (%s) %s [%s-%s]\n' % (loc, severity, message, addon, errorId))
|
sys.stderr.write('%s (%s) %s [%s-%s]\n' % (loc, severity, message, addon, errorId))
|
||||||
|
global EXIT_CODE
|
||||||
|
EXIT_CODE = 1
|
||||||
|
|
|
@ -38,3 +38,5 @@ for arg in sys.argv[1:]:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
cppcheckdata.reportError(token, 'information', 'found a cast', 'findcasts', 'cast')
|
cppcheckdata.reportError(token, 'information', 'found a cast', 'findcasts', 'cast')
|
||||||
|
|
||||||
|
sys.exit(cppcheckdata.EXIT_CODE)
|
||||||
|
|
|
@ -163,3 +163,5 @@ 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)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
sys.exit(cppcheckdata.EXIT_CODE)
|
||||||
|
|
|
@ -3126,7 +3126,6 @@ def main():
|
||||||
if args.severity:
|
if args.severity:
|
||||||
checker.setSeverity(args.severity)
|
checker.setSeverity(args.severity)
|
||||||
|
|
||||||
exitCode = 0
|
|
||||||
for item in args.dumpfile:
|
for item in args.dumpfile:
|
||||||
checker.parseDump(item)
|
checker.parseDump(item)
|
||||||
|
|
||||||
|
@ -3134,6 +3133,7 @@ def main():
|
||||||
verify_expected = checker.get_verify_expected()
|
verify_expected = checker.get_verify_expected()
|
||||||
verify_actual = checker.get_verify_actual()
|
verify_actual = checker.get_verify_actual()
|
||||||
|
|
||||||
|
exitCode = 0
|
||||||
for expected in verify_expected:
|
for expected in verify_expected:
|
||||||
if expected not in verify_actual:
|
if expected not in verify_actual:
|
||||||
print('Expected but not seen: ' + expected)
|
print('Expected but not seen: ' + expected)
|
||||||
|
@ -3150,41 +3150,38 @@ def main():
|
||||||
if exitCode != 0:
|
if exitCode != 0:
|
||||||
sys.exit(exitCode)
|
sys.exit(exitCode)
|
||||||
|
|
||||||
# Under normal operation exit with a non-zero exit code
|
if settings.verify:
|
||||||
# if there were any violations.
|
sys.exit(exitCode)
|
||||||
if not settings.verify:
|
|
||||||
number_of_violations = len(checker.get_violations())
|
|
||||||
if number_of_violations > 0:
|
|
||||||
exitCode = 1
|
|
||||||
|
|
||||||
if settings.show_summary:
|
number_of_violations = len(checker.get_violations())
|
||||||
print("\nMISRA rules violations found:\n\t%s\n" % (
|
if number_of_violations > 0:
|
||||||
"\n\t".join(["%s: %d" % (viol, len(checker.get_violations(viol))) for viol in
|
if settings.show_summary:
|
||||||
checker.get_violation_types()])))
|
print("\nMISRA rules violations found:\n\t%s\n" % (
|
||||||
|
"\n\t".join(["%s: %d" % (viol, len(checker.get_violations(viol))) for viol in
|
||||||
|
checker.get_violation_types()])))
|
||||||
|
|
||||||
rules_violated = {}
|
rules_violated = {}
|
||||||
for severity, ids in checker.get_violations():
|
for severity, ids in checker.get_violations():
|
||||||
for misra_id in ids:
|
for misra_id in ids:
|
||||||
rules_violated[misra_id] = rules_violated.get(misra_id, 0) + 1
|
rules_violated[misra_id] = rules_violated.get(misra_id, 0) + 1
|
||||||
print("MISRA rules violated:")
|
print("MISRA rules violated:")
|
||||||
convert = lambda text: int(text) if text.isdigit() else text
|
convert = lambda text: int(text) if text.isdigit() else text
|
||||||
misra_sort = lambda key: [convert(c) for c in re.split(r'[\.-]([0-9]*)', key)]
|
misra_sort = lambda key: [convert(c) for c in re.split(r'[\.-]([0-9]*)', key)]
|
||||||
for misra_id in sorted(rules_violated.keys(), key=misra_sort):
|
for misra_id in sorted(rules_violated.keys(), key=misra_sort):
|
||||||
res = re.match(r'misra-c2012-([0-9]+)\\.([0-9]+)', misra_id)
|
res = re.match(r'misra-c2012-([0-9]+)\\.([0-9]+)', misra_id)
|
||||||
if res is None:
|
if res is None:
|
||||||
num = 0
|
num = 0
|
||||||
else:
|
else:
|
||||||
num = int(res.group(1)) * 100 + int(res.group(2))
|
num = int(res.group(1)) * 100 + int(res.group(2))
|
||||||
severity = '-'
|
severity = '-'
|
||||||
if num in checker.ruleTexts:
|
if num in checker.ruleTexts:
|
||||||
severity = checker.ruleTexts[num].cppcheck_severity
|
severity = checker.ruleTexts[num].cppcheck_severity
|
||||||
print("\t%15s (%s): %d" % (misra_id, severity, rules_violated[misra_id]))
|
print("\t%15s (%s): %d" % (misra_id, severity, rules_violated[misra_id]))
|
||||||
|
|
||||||
if args.show_suppressed_rules:
|
if args.show_suppressed_rules:
|
||||||
checker.showSuppressedRules()
|
checker.showSuppressedRules()
|
||||||
|
|
||||||
sys.exit(exitCode)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
sys.exit(cppcheckdata.EXIT_CODE)
|
||||||
|
|
|
@ -87,3 +87,5 @@ for arg in sys.argv[1:]:
|
||||||
if not res:
|
if not res:
|
||||||
reportError(
|
reportError(
|
||||||
scope.bodyStart, 'style', 'Function ' + scope.className + ' violates naming convention', 'functionName')
|
scope.bodyStart, 'style', 'Function ' + scope.className + ' violates naming convention', 'functionName')
|
||||||
|
|
||||||
|
sys.exit(cppcheckdata.EXIT_CODE)
|
||||||
|
|
|
@ -249,4 +249,5 @@ if __name__ == "__main__":
|
||||||
if len(errors):
|
if len(errors):
|
||||||
print('Found errors: {}'.format(len(errors)))
|
print('Found errors: {}'.format(len(errors)))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
|
@ -34,3 +34,5 @@ for arg in sys.argv[1:]:
|
||||||
for cfg in data.iterconfigurations():
|
for cfg in data.iterconfigurations():
|
||||||
print('Checking %s, config %s...' % (arg, cfg.name))
|
print('Checking %s, config %s...' % (arg, cfg.name))
|
||||||
checkstatic(cfg)
|
checkstatic(cfg)
|
||||||
|
|
||||||
|
sys.exit(cppcheckdata.EXIT_CODE)
|
||||||
|
|
|
@ -243,17 +243,9 @@ if __name__ == '__main__':
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
for dumpfile in args.dumpfile:
|
for dumpfile in args.dumpfile:
|
||||||
if not os.path.isfile(dumpfile):
|
|
||||||
print("Error: File not found: %s" % dumpfile)
|
|
||||||
sys.exit(127)
|
|
||||||
if not os.access(dumpfile, os.R_OK):
|
|
||||||
print("Error: Permission denied: %s" % dumpfile)
|
|
||||||
sys.exit(13)
|
|
||||||
if not args.quiet:
|
if not args.quiet:
|
||||||
print('Checking ' + dumpfile + '...')
|
print('Checking ' + dumpfile + '...')
|
||||||
|
|
||||||
y2038safe = check_y2038_safe(dumpfile, quiet)
|
check_y2038_safe(dumpfile, quiet)
|
||||||
if not y2038safe and exit_code == 0:
|
|
||||||
exit_code = 1
|
|
||||||
|
|
||||||
sys.exit(exit_code)
|
sys.exit(cppcheckdata.EXIT_CODE)
|
||||||
|
|
Loading…
Reference in New Issue