Skip to content

Commit

Permalink
diff-quality plugins should support "--options" and report files (#305)
Browse files Browse the repository at this point in the history
  • Loading branch information
barrywhart authored Dec 10, 2022
1 parent 6c0a615 commit 32a0e20
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions diff_cover/diff_quality_tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def main(argv=None, directory=None):
if first_char == last_char and first_char in ('"', "'"):
user_options = user_options[1:-1]
reporter = None
reporter_factory_fn = None
driver = QUALITY_DRIVERS.get(tool)
if driver is None:
# The requested tool is not built into diff_cover. See if another Python
Expand All @@ -321,29 +322,29 @@ def main(argv=None, directory=None):
)
for hookimpl in hooks.get_hookimpls():
if hookimpl.plugin_name == tool:
reporter = hookimpl.function()
reporter_factory_fn = hookimpl.function
break

if reporter or driver:
if reporter or driver or reporter_factory_fn:
input_reports = []
try:
for path in arg_dict["input_reports"]:
try:
input_reports.append(open(path, "rb"))
except OSError:
LOGGER.error("Could not load report '%s'", path)
return 1
if driver is not None:
# If we've been given pre-generated reports,
# try to open the files

for path in arg_dict["input_reports"]:
try:
input_reports.append(open(path, "rb"))
except OSError:
LOGGER.error("Could not load report '%s'", path)
return 1

if arg_dict["report_root_path"]:
driver.add_driver_args(
report_root_path=arg_dict["report_root_path"]
)

reporter = QualityReporter(driver, input_reports, user_options)
elif reporter_factory_fn:
reporter = reporter_factory_fn(reports=input_reports, options=user_options)

percent_passing = generate_quality_report(
reporter,
Expand Down

0 comments on commit 32a0e20

Please sign in to comment.