fixup reporter work
This commit is contained in:
committed by
Tamara Dahlgren
parent
b996d65a96
commit
d6a497540d
@@ -263,7 +263,8 @@ def install(parser, args, **kwargs):
|
|||||||
tty.warn("Deprecated option: --run-tests: use --test=all instead")
|
tty.warn("Deprecated option: --run-tests: use --test=all instead")
|
||||||
|
|
||||||
# 1. Abstract specs from cli
|
# 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:
|
if args.log_file:
|
||||||
reporter.filename = args.log_file
|
reporter.filename = args.log_file
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
import spack.cmd
|
import spack.cmd
|
||||||
import spack.cmd.common.arguments as arguments
|
import spack.cmd.common.arguments as arguments
|
||||||
import spack.report
|
import spack.report
|
||||||
|
import spack.package
|
||||||
|
|
||||||
description = "run spack's tests for an install"
|
description = "run spack's tests for an install"
|
||||||
section = "administrator"
|
section = "administrator"
|
||||||
@@ -90,7 +91,8 @@ def test(parser, args):
|
|||||||
|
|
||||||
# Set up reporter
|
# Set up reporter
|
||||||
setattr(args, 'package', [s.format() for s in specs_to_test])
|
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 not reporter.filename:
|
||||||
if args.log_file:
|
if args.log_file:
|
||||||
if os.path.isabs(args.log_file):
|
if os.path.isabs(args.log_file):
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
def fetch_log(pkg, do_fn, dir):
|
def fetch_log(pkg, do_fn, dir):
|
||||||
log_files = {
|
log_files = {
|
||||||
'do_install': pkg.build_log_path,
|
'_install_task': pkg.build_log_path,
|
||||||
'do_test': os.path.join(dir, pkg.test_log_name),
|
'do_test': os.path.join(dir, pkg.test_log_name),
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
@@ -130,7 +130,7 @@ def gather_info(do_fn):
|
|||||||
"""
|
"""
|
||||||
@functools.wraps(do_fn)
|
@functools.wraps(do_fn)
|
||||||
def wrapper(instance, *args, **kwargs):
|
def wrapper(instance, *args, **kwargs):
|
||||||
if isinstance(instance, PackageBase):
|
if isinstance(instance, spack.package.PackageBase):
|
||||||
pkg = instance
|
pkg = instance
|
||||||
elif hasattr(args[0], 'pkg'):
|
elif hasattr(args[0], 'pkg'):
|
||||||
pkg = args[0].pkg
|
pkg = args[0].pkg
|
||||||
@@ -152,12 +152,12 @@ def wrapper(instance, *args, **kwargs):
|
|||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
value = None
|
value = None
|
||||||
try:
|
try:
|
||||||
value = _install_task(instance, *args, **kwargs)
|
value = do_fn(instance, *args, **kwargs)
|
||||||
package['result'] = 'success'
|
package['result'] = 'success'
|
||||||
package['stdout'] = fetch_log(pkg, do_fn, self.dir)
|
package['stdout'] = fetch_log(pkg, do_fn, self.dir)
|
||||||
package['installed_from_binary_cache'] = \
|
package['installed_from_binary_cache'] = \
|
||||||
pkg.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
|
return
|
||||||
|
|
||||||
except spack.build_environment.InstallError as e:
|
except spack.build_environment.InstallError as e:
|
||||||
@@ -240,22 +240,25 @@ class collect_info(object):
|
|||||||
|
|
||||||
# The file 'junit.xml' is written when exiting
|
# The file 'junit.xml' is written when exiting
|
||||||
# the context
|
# the context
|
||||||
specs = [Spec('hdf5').concretized()]
|
s = [Spec('hdf5').concretized()]
|
||||||
with collect_info(specs, 'junit', 'junit.xml'):
|
with collect_info(PackageBase, do_install, s, 'junit', 'a.xml'):
|
||||||
# A report will be generated for these specs...
|
# A report will be generated for these specs...
|
||||||
for spec in specs:
|
for spec in s:
|
||||||
spec.do_install()
|
getattr(class, function)(spec)
|
||||||
# ...but not for this one
|
# ...but not for this one
|
||||||
Spec('zlib').concretized().do_install()
|
Spec('zlib').concretized().do_install()
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
class: class on which to wrap a function
|
||||||
|
function: function to wrap
|
||||||
format_name (str or None): one of the supported formats
|
format_name (str or None): one of the supported formats
|
||||||
args (dict): args passed to spack install
|
args (dict): args passed to function
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: when ``format_name`` is not in ``valid_formats``
|
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.function = function
|
||||||
self.filename = None
|
self.filename = None
|
||||||
if args.cdash_upload_url:
|
if args.cdash_upload_url:
|
||||||
@@ -280,7 +283,8 @@ def concretization_report(self, msg):
|
|||||||
def __enter__(self):
|
def __enter__(self):
|
||||||
if self.format_name:
|
if self.format_name:
|
||||||
# Start the collector and patch self.function on appropriate class
|
# 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__()
|
self.collector.__enter__()
|
||||||
|
|
||||||
def __exit__(self, exc_type, exc_val, exc_tb):
|
def __exit__(self, exc_type, exc_val, exc_tb):
|
||||||
|
|||||||
Reference in New Issue
Block a user