[tor-commits] [tor/master] Practracker: new flags to control output.
dgoulet at torproject.org
dgoulet at torproject.org
Thu Aug 1 14:20:43 UTC 2019
commit 3f303c102a3adea24d8a3f513c8528eb417d5283
Author: Nick Mathewson <nickm at torproject.org>
Date: Tue Jul 30 11:49:50 2019 -0400
Practracker: new flags to control output.
These flags let you suppress the message about the number of
problems and warnings, and let you control the thresholds above
which something counts as a problem.
I need this for testing.
---
scripts/maint/practracker/practracker.py | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/scripts/maint/practracker/practracker.py b/scripts/maint/practracker/practracker.py
index 3bf16dcde..fb6649bdc 100755
--- a/scripts/maint/practracker/practracker.py
+++ b/scripts/maint/practracker/practracker.py
@@ -36,7 +36,6 @@ MAX_FUNCTION_SIZE = 100 # lines
# Recommended number of #includes
MAX_INCLUDE_COUNT = 50
-
# Map from problem type to functions that adjust for tolerance
TOLERANCE_FNS = {
'include-count': lambda n: int(n*1.1),
@@ -49,12 +48,6 @@ TOLERANCE_FNS = {
# The Tor source code topdir
TOR_TOPDIR = None
-# ProblemFilter singleton.
-FILTER = problem.ProblemFilter()
-FILTER.addThreshold(problem.FileSizeItem("*", MAX_FILE_SIZE))
-FILTER.addThreshold(problem.IncludeCountItem("*", MAX_INCLUDE_COUNT))
-FILTER.addThreshold(problem.FunctionSizeItem("*", MAX_FUNCTION_SIZE))
-
#######################################################
if sys.version_info[0] <= 2:
@@ -166,6 +159,14 @@ def main(argv):
help="Override the location for the exceptions file")
parser.add_argument("--strict", action="store_true",
help="Make all warnings into errors")
+ parser.add_argument("--terse", action="store_true",
+ help="Do not emit helpful instructions.")
+ parser.add_argument("--max-file-size", default=MAX_FILE_SIZE,
+ help="Maximum lines per C file size")
+ parser.add_argument("--max-include-count", default=MAX_INCLUDE_COUNT,
+ help="Maximum includes per C file")
+ parser.add_argument("--max-function-size", default=MAX_FUNCTION_SIZE,
+ help="Maximum lines per function")
parser.add_argument("topdir", default=".", nargs="?",
help="Top-level directory for the tor source")
args = parser.parse_args(argv[1:])
@@ -177,6 +178,12 @@ def main(argv):
else:
exceptions_file = os.path.join(TOR_TOPDIR, "scripts/maint/practracker", EXCEPTIONS_FNAME)
+ # 0) Configure our thresholds of "what is a problem actually"
+ filt = problem.ProblemFilter()
+ filt.addThreshold(problem.FileSizeItem("*", int(args.max_file_size)))
+ filt.addThreshold(problem.IncludeCountItem("*", int(args.max_include_count)))
+ filt.addThreshold(problem.FunctionSizeItem("*", int(args.max_function_size)))
+
# 1) Get all the .c files we care about
files_list = util.get_tor_c_files(TOR_TOPDIR)
@@ -198,7 +205,7 @@ def main(argv):
# 3) Go through all the files and report problems if they are not exceptions
found_new_issues = 0
- for item in FILTER.filter(consider_all_metrics(files_list)):
+ for item in filt.filter(consider_all_metrics(files_list)):
status = ProblemVault.register_problem(item)
if status == problem.STATUS_ERR:
print(item)
@@ -212,7 +219,7 @@ def main(argv):
sys.exit(0)
# If new issues were found, try to give out some advice to the developer on how to resolve it.
- if found_new_issues and not args.regen:
+ if found_new_issues and not args.regen and not args.terse:
new_issues_str = """\
FAILURE: practracker found {} new problem(s) in the code: see warnings above.
More information about the tor-commits
mailing list