| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e74f199 commit 09e98a4
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -44,6 +44,7 @@ | |||
| 44 | 44 | import codecs | |
| 45 | 45 | import copy | |
| 46 | 46 | import getopt | |
| 47 | + import logging | ||
| 47 | 48 | import math # for log | |
| 48 | 49 | import os | |
| 49 | 50 | import re | |
@@ -53,10 +54,13 @@ | |||
| 53 | 54 | import unicodedata | |
| 54 | 55 | ||
| 55 | 56 | ||
| 57 | + logger = logging.getLogger('testrunner') | ||
| 58 | + | ||
| 59 | + | ||
| 56 | 60 | _USAGE = """ | |
| 57 | 61 | Syntax: cpplint.py [--verbose=#] [--output=vs7] [--filter=-x,+y,...] | |
| 58 | 62 | [--counting=total|toplevel|detailed] [--root=subdir] | |
| 59 | - [--linelength=digits] | ||
| 63 | + [--linelength=digits] [--logfile=filename] | ||
| 60 | 64 | <file> [file] ... | |
| 61 | 65 | ||
| 62 | 66 | The style guidelines this tries to follow are those in | |
@@ -134,6 +138,9 @@ | |||
| 134 | 138 | Examples: | |
| 135 | 139 | --extensions=hpp,cpp | |
| 136 | 140 | ||
| 141 | + logfile=filename | ||
| 142 | + Write TAP output to a logfile. | ||
| 143 | + | ||
| 137 | 144 | cpplint.py supports per-directory configurations specified in CPPLINT.cfg | |
| 138 | 145 | files. CPPLINT.cfg file can contain a number of key=value pairs. | |
| 139 | 146 | Currently the following options are supported: | |
@@ -1190,6 +1197,15 @@ def Error(filename, linenum, category, confidence, message): | |||
| 1190 | 1197 | elif _cpplint_state.output_format == 'eclipse': | |
| 1191 | 1198 | sys.stderr.write('%s:%s: warning: %s [%s] [%d]\n' % ( | |
| 1192 | 1199 | filename, linenum, message, category, confidence)) | |
| 1200 | + elif _cpplint_state.output_format == 'tap': | ||
| 1201 | + template = ('not ok %(filename)s\n' | ||
| 1202 | + ' ---\n' | ||
| 1203 | + ' message: %(message)s\n' | ||
| 1204 | + ' data:\n' | ||
| 1205 | + ' line: %(linenum)d\n' | ||
| 1206 | + ' ruleId: %(category)s\n' | ||
| 1207 | + ' ...') | ||
| 1208 | + logger.info(template % locals()) | ||
| 1193 | 1209 | else: | |
| 1194 | 1210 | sys.stderr.write('%s:%s: %s [%s] [%d]\n' % ( | |
| 1195 | 1211 | filename, linenum, message, category, confidence)) | |
@@ -5980,7 +5996,6 @@ def ProcessFile(filename, vlevel, extra_check_functions=[]): | |||
| 5980 | 5996 | Error(filename, linenum, 'whitespace/newline', 1, | |
| 5981 | 5997 | 'Unexpected \\r (^M) found; better to use only \\n') | |
| 5982 | 5998 | ||
| 5983 | - sys.stderr.write('Done processing %s\n' % filename) | ||
| 5984 | 5999 | _RestoreFilters() | |
| 5985 | 6000 | ||
| 5986 | 6001 | ||
@@ -6021,6 +6036,7 @@ def ParseArguments(args): | |||
| 6021 | 6036 | (opts, filenames) = getopt.getopt(args, '', ['help', 'output=', 'verbose=', | |
| 6022 | 6037 | 'counting=', | |
| 6023 | 6038 | 'filter=', | |
| 6039 | + 'logfile=', | ||
| 6024 | 6040 | 'root=', | |
| 6025 | 6041 | 'linelength=', | |
| 6026 | 6042 | 'extensions=']) | |
@@ -6036,8 +6052,9 @@ def ParseArguments(args): | |||
| 6036 | 6052 | if opt == '--help': | |
| 6037 | 6053 | PrintUsage(None) | |
| 6038 | 6054 | elif opt == '--output': | |
| 6039 | - if val not in ('emacs', 'vs7', 'eclipse'): | ||
| 6040 | - PrintUsage('The only allowed output formats are emacs, vs7 and eclipse.') | ||
| 6055 | + if val not in ('emacs', 'vs7', 'eclipse', 'tap'): | ||
| 6056 | + PrintUsage( | ||
| 6057 | + 'The only allowed output formats are emacs, vs7, eclipse and tap.') | ||
| 6041 | 6058 | output_format = val | |
| 6042 | 6059 | elif opt == '--verbose': | |
| 6043 | 6060 | verbosity = int(val) | |
@@ -6064,6 +6081,8 @@ def ParseArguments(args): | |||
| 6064 | 6081 | _valid_extensions = set(val.split(',')) | |
| 6065 | 6082 | except ValueError: | |
| 6066 | 6083 | PrintUsage('Extensions must be comma seperated list.') | |
| 6084 | + elif opt == '--logfile': | ||
| 6085 | + logger.addHandler(logging.FileHandler(val, mode='wb')) | ||
| 6067 | 6086 | ||
| 6068 | 6087 | if not filenames: | |
| 6069 | 6088 | PrintUsage('No files were specified.') | |
@@ -6086,6 +6105,12 @@ def main(): | |||
| 6086 | 6105 | codecs.getwriter('utf8'), | |
| 6087 | 6106 | 'replace') | |
| 6088 | 6107 | ||
| 6108 | + logger.addHandler(logging.StreamHandler(sys.stdout)) | ||
| 6109 | + logger.setLevel(logging.INFO) | ||
| 6110 | + | ||
| 6111 | + if _cpplint_state.output_format == 'tap': | ||
| 6112 | + logger.info('TAP version 13') | ||
| 6113 | + | ||
| 6089 | 6114 | _cpplint_state.ResetErrorCounts() | |
| 6090 | 6115 | for filename in filenames: | |
| 6091 | 6116 | ProcessFile(filename, _cpplint_state.verbose_level) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments