Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

diff-quality plugins should support "--options" and report files #305

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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