From e4e8c72fa1f713062f59304764c36f39f761480e Mon Sep 17 00:00:00 2001 From: Zack Galbreath Date: Tue, 10 Apr 2018 11:07:09 -0400 Subject: Initialize report generator before parsing specs This will allow us to generate reports for concretization errors --- lib/spack/spack/cmd/install.py | 10 ++++++++-- lib/spack/spack/report.py | 7 ++----- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/spack/spack/cmd/install.py b/lib/spack/spack/cmd/install.py index 99572a1ff2..12c6551716 100644 --- a/lib/spack/spack/cmd/install.py +++ b/lib/spack/spack/cmd/install.py @@ -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 diff --git a/lib/spack/spack/report.py b/lib/spack/spack/report.py index 5c4db754c6..132a59ecba 100644 --- a/lib/spack/spack/report.py +++ b/lib/spack/spack/report.py @@ -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): -- cgit v1.2.3-70-g09d2