Initialize report generator before parsing specs

This will allow us to generate reports for concretization errors
This commit is contained in:
Zack Galbreath 2018-04-10 11:07:09 -04:00 committed by Todd Gamblin
parent de01d70ae4
commit e4e8c72fa1
2 changed files with 10 additions and 7 deletions

View File

@ -191,6 +191,10 @@ def install(parser, args, **kwargs):
tty.warn("Deprecated option: --run-tests: use --test=all instead")
# 1. Abstract specs from cli
reporter = spack.report.collect_info(args.log_format)
if args.log_file:
reporter.filename = args.log_file
specs = spack.cmd.parse_specs(args.package)
if args.test == 'all' or args.run_tests:
spack.package_testing.test_all()
@ -216,8 +220,10 @@ def install(parser, args, **kwargs):
if len(specs) == 0:
tty.die('The `spack install` command requires a spec to install.')
filename = args.log_file or default_log_file(specs[0])
with spack.report.collect_info(specs, args.log_format, filename):
if not args.log_file:
reporter.filename = default_log_file(specs[0])
reporter.specs = specs
with reporter:
if args.overwrite:
# If we asked to overwrite an existing spec we must ensure that:
# 1. We have only one spec

View File

@ -249,20 +249,17 @@ class collect_info(object):
Raises:
ValueError: when ``format_name`` is not in ``valid_formats``
"""
def __init__(self, specs, format_name, filename):
self.specs = specs
def __init__(self, format_name):
self.format_name = format_name
# Check that the format is valid
if format_name not in itertools.chain(valid_formats, [None]):
raise ValueError('invalid report type: {0}'.format(format_name))
self.filename = filename
self.collector = InfoCollector(specs) if self.format_name else None
def __enter__(self):
if self.format_name:
# Start the collector and patch PackageBase.do_install
self.collector = InfoCollector(self.specs)
self.collector.__enter__()
def __exit__(self, exc_type, exc_val, exc_tb):