Commit 8919d3f8 by Christine Lytwynec

Store count of pep8 and pylint violations to files in reports dir

parent 006b06dd
...@@ -75,6 +75,9 @@ def run_pylint(options): ...@@ -75,6 +75,9 @@ def run_pylint(options):
violations_limit = int(getattr(options, 'limit', -1)) violations_limit = int(getattr(options, 'limit', -1))
errors = getattr(options, 'errors', False) errors = getattr(options, 'errors', False)
systems = getattr(options, 'system', ALL_SYSTEMS).split(',') systems = getattr(options, 'system', ALL_SYSTEMS).split(',')
# Make sure the metrics subdirectory exists
Env.METRICS_DIR.makedirs_p()
for system in systems: for system in systems:
# Directory to put the pylint report in. # Directory to put the pylint report in.
...@@ -114,7 +117,15 @@ def run_pylint(options): ...@@ -114,7 +117,15 @@ def run_pylint(options):
num_violations += _count_pylint_violations( num_violations += _count_pylint_violations(
"{report_dir}/pylint.report".format(report_dir=report_dir)) "{report_dir}/pylint.report".format(report_dir=report_dir))
print("Number of pylint violations: " + str(num_violations)) # Print number of violations to log
violations_count_str = "Number of pylint violations: " + str(num_violations)
print(violations_count_str)
# Also write the number of violations to a file
with open(Env.METRICS_DIR / "pylint", "w") as f:
f.write(violations_count_str)
# Fail number of violations is greater than the limit
if num_violations > violations_limit > -1: if num_violations > violations_limit > -1:
raise Exception("Failed. Too many pylint violations. " raise Exception("Failed. Too many pylint violations. "
"The limit is {violations_limit}.".format(violations_limit=violations_limit)) "The limit is {violations_limit}.".format(violations_limit=violations_limit))
...@@ -154,6 +165,9 @@ def run_pep8(options): ...@@ -154,6 +165,9 @@ def run_pep8(options):
report_dir = (Env.REPORT_DIR / 'pep8') report_dir = (Env.REPORT_DIR / 'pep8')
report_dir.rmtree(ignore_errors=True) report_dir.rmtree(ignore_errors=True)
report_dir.makedirs_p() report_dir.makedirs_p()
# Make sure the metrics subdirectory exists
Env.METRICS_DIR.makedirs_p()
for system in systems: for system in systems:
sh('pep8 {system} | tee {report_dir}/pep8.report -a'.format(system=system, report_dir=report_dir)) sh('pep8 {system} | tee {report_dir}/pep8.report -a'.format(system=system, report_dir=report_dir))
...@@ -162,7 +176,15 @@ def run_pep8(options): ...@@ -162,7 +176,15 @@ def run_pep8(options):
"{report_dir}/pep8.report".format(report_dir=report_dir) "{report_dir}/pep8.report".format(report_dir=report_dir)
) )
print("Number of pep8 violations: {count}".format(count=count)) # Print number of violations to log
violations_count_str = "Number of pep8 violations: {count}".format(count=count)
print(violations_count_str)
# Also write the number of violations to a file
with open(Env.METRICS_DIR / "pep8", "w") as f:
f.write(violations_count_str)
# Fail if any violations are found
if count: if count:
raise Exception( raise Exception(
"Too many pep8 violations. Number of violations found: {count}.".format( "Too many pep8 violations. Number of violations found: {count}.".format(
......
...@@ -20,6 +20,7 @@ class Env(object): ...@@ -20,6 +20,7 @@ class Env(object):
# Reports Directory # Reports Directory
REPORT_DIR = REPO_ROOT / 'reports' REPORT_DIR = REPO_ROOT / 'reports'
METRICS_DIR = REPORT_DIR / 'metrics'
# Bok_choy dirs # Bok_choy dirs
BOK_CHOY_DIR = REPO_ROOT / "common" / "test" / "acceptance" BOK_CHOY_DIR = REPO_ROOT / "common" / "test" / "acceptance"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment