Introduce new flag --fail-on-defect to pio check

This commit is contained in:
valeros
2019-10-25 15:40:50 +03:00
parent 8a6892bf3c
commit 4486a85d4c
2 changed files with 37 additions and 4 deletions

View File

@@ -56,6 +56,7 @@ from platformio.project.helpers import find_project_dir_above, get_project_dir
@click.option("-s", "--silent", is_flag=True)
@click.option("-v", "--verbose", is_flag=True)
@click.option("--json-output", is_flag=True)
@click.option("--fail-on-defect", is_flag=True)
def cli(
environment,
project_dir,
@@ -66,6 +67,7 @@ def cli(
silent,
verbose,
json_output,
fail_on_defect
):
app.set_session_var("custom_project_conf", project_conf)
@@ -134,9 +136,11 @@ def cli(
result["defects"] = ct.get_defects()
result["duration"] = time() - result["duration"]
result["succeeded"] = rc == 0 and not any(
d.severity == DefectItem.SEVERITY_HIGH for d in result["defects"]
)
result["succeeded"] = rc == 0
if fail_on_defect:
result["succeeded"] = rc == 0 and not any(
d.severity == DefectItem.SEVERITY_HIGH for d in result["defects"])
result["stats"] = collect_component_stats(result)
results.append(result)
@@ -144,7 +148,10 @@ def cli(
click.echo("\n".join(repr(d) for d in result["defects"]))
if not json_output and not silent:
if not result["defects"]:
if rc != 0:
click.echo("Error: %s failed to perform check! Please "
"examine tool output in verbose mode." % tool)
elif not result["defects"]:
click.echo("No defects found")
print_processing_footer(result)