Mercurial > hg-stable
diff contrib/check-code.py @ 41829:519b2faea261
contrib: change return value of file checking function of check-code.py
This is a part of preparation to apply checking with check-code.py on
code fragments embedded in *.t test scripts.
After this patch, caller of _checkfiledata() can count number of
errors in each code fragments of an actual file.
This will be useful to share --per-file limitation by all embedded
code fragments.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Fri, 01 Mar 2019 02:53:09 +0900 |
parents | 7a139fc60eb0 |
children | 6d6bd9039ecd |
line wrap: on
line diff
--- a/contrib/check-code.py Fri Mar 01 02:53:09 2019 +0900 +++ b/contrib/check-code.py Fri Mar 01 02:53:09 2019 +0900 @@ -669,8 +669,9 @@ print("Skipping %s it has no-che?k-code (glob)" % f) return "Skip" # skip checking this file - if not _checkfiledata(name, f, pre, filters, pats, context, - logfunc, maxerr, warnings, blame, debug, lineno): + fc = _checkfiledata(name, f, pre, filters, pats, context, + logfunc, maxerr, warnings, blame, debug, lineno) + if fc: result = False return result @@ -695,13 +696,12 @@ :debug: whether debug information should be displayed :lineno: whether lineno should be displayed at error reporting - return True if no error is found, False otherwise. + returns number of detected errors. """ blamecache = context['blamecache'] fc = 0 pre = post = filedata - result = True if True: # TODO: get rid of this redundant 'if' block for p, r in filters: @@ -760,7 +760,6 @@ bd = '%s@%s' % (bu, br) errors.append((f, lineno and n + 1, l, msg, bd)) - result = False errors.sort() for e in errors: @@ -770,7 +769,7 @@ print(" (too many errors, giving up)") break - return result + return fc def main(): parser = optparse.OptionParser("%prog [options] [files | -]")