fixup reporter work

This commit is contained in:
Gregory Becker
2020-03-18 16:52:01 -07:00
committed by Tamara Dahlgren
parent b996d65a96
commit d6a497540d
3 changed files with 20 additions and 13 deletions

View File

@@ -263,7 +263,8 @@ 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('do_install', args.log_format, args)
reporter = spack.report.collect_info(
spack.package.PackageInstaller, '_install_task', args.log_format, args)
if args.log_file:
reporter.filename = args.log_file

View File

@@ -15,6 +15,7 @@
import spack.cmd
import spack.cmd.common.arguments as arguments
import spack.report
import spack.package
description = "run spack's tests for an install"
section = "administrator"
@@ -90,7 +91,8 @@ def test(parser, args):
# Set up reporter
setattr(args, 'package', [s.format() for s in specs_to_test])
reporter = spack.report.collect_info('do_test', args.log_format, args)
reporter = spack.report.collect_info(
spack.package.PackageBase, 'do_test', args.log_format, args)
if not reporter.filename:
if args.log_file:
if os.path.isabs(args.log_file):

View File

@@ -36,7 +36,7 @@
def fetch_log(pkg, do_fn, dir):
log_files = {
'do_install': pkg.build_log_path,
'_install_task': pkg.build_log_path,
'do_test': os.path.join(dir, pkg.test_log_name),
}
try:
@@ -130,7 +130,7 @@ def gather_info(do_fn):
"""
@functools.wraps(do_fn)
def wrapper(instance, *args, **kwargs):
if isinstance(instance, PackageBase):
if isinstance(instance, spack.package.PackageBase):
pkg = instance
elif hasattr(args[0], 'pkg'):
pkg = args[0].pkg
@@ -152,12 +152,12 @@ def wrapper(instance, *args, **kwargs):
start_time = time.time()
value = None
try:
value = _install_task(instance, *args, **kwargs)
value = do_fn(instance, *args, **kwargs)
package['result'] = 'success'
package['stdout'] = fetch_log(pkg, do_fn, self.dir)
package['installed_from_binary_cache'] = \
pkg.installed_from_binary_cache
if do_fn.__name__ == 'do_install' and installed_on_entry:
if do_fn.__name__ == '_install_task' and installed_on_entry:
return
except spack.build_environment.InstallError as e:
@@ -240,22 +240,25 @@ class collect_info(object):
# The file 'junit.xml' is written when exiting
# the context
specs = [Spec('hdf5').concretized()]
with collect_info(specs, 'junit', 'junit.xml'):
s = [Spec('hdf5').concretized()]
with collect_info(PackageBase, do_install, s, 'junit', 'a.xml'):
# A report will be generated for these specs...
for spec in specs:
spec.do_install()
for spec in s:
getattr(class, function)(spec)
# ...but not for this one
Spec('zlib').concretized().do_install()
Args:
class: class on which to wrap a function
function: function to wrap
format_name (str or None): one of the supported formats
args (dict): args passed to spack install
args (dict): args passed to function
Raises:
ValueError: when ``format_name`` is not in ``valid_formats``
"""
def __init__(self, function, format_name, args):
def __init__(self, cls, function, format_name, args):
self.cls = cls
self.function = function
self.filename = None
if args.cdash_upload_url:
@@ -280,7 +283,8 @@ def concretization_report(self, msg):
def __enter__(self):
if self.format_name:
# Start the collector and patch self.function on appropriate class
self.collector = InfoCollector(self.function, self.specs, self.dir)
self.collector = InfoCollector(
self.cls, self.function, self.specs, self.dir)
self.collector.__enter__()
def __exit__(self, exc_type, exc_val, exc_tb):