add reporting format options to spack test
This commit is contained in:
committed by
Tamara Dahlgren
parent
4151224ef2
commit
bfb97e4d57
@@ -275,3 +275,53 @@ def no_checksum():
|
||||
return Args(
|
||||
'-n', '--no-checksum', action='store_true', default=False,
|
||||
help="do not use checksums to verify downloaded files (unsafe)")
|
||||
|
||||
|
||||
def add_cdash_args(subparser, add_help):
|
||||
cdash_help = {}
|
||||
if add_help:
|
||||
cdash_help['upload-url'] = "CDash URL where reports will be uploaded"
|
||||
cdash_help['build'] = """The name of the build that will be reported to CDash.
|
||||
Defaults to spec of the package to operate on."""
|
||||
cdash_help['site'] = """The site name that will be reported to CDash.
|
||||
Defaults to current system hostname."""
|
||||
cdash_help['track'] = """Results will be reported to this group on CDash.
|
||||
Defaults to Experimental."""
|
||||
cdash_help['buildstamp'] = """Instead of letting the CDash reporter prepare the
|
||||
buildstamp which, when combined with build name, site and project,
|
||||
uniquely identifies the build, provide this argument to identify
|
||||
the build yourself. Format: %%Y%%m%%d-%%H%%M-[cdash-track]"""
|
||||
else:
|
||||
cdash_help['upload-url'] = argparse.SUPPRESS
|
||||
cdash_help['build'] = argparse.SUPPRESS
|
||||
cdash_help['site'] = argparse.SUPPRESS
|
||||
cdash_help['track'] = argparse.SUPPRESS
|
||||
cdash_help['buildstamp'] = argparse.SUPPRESS
|
||||
|
||||
subparser.add_argument(
|
||||
'--cdash-upload-url',
|
||||
default=None,
|
||||
help=cdash_help['upload-url']
|
||||
)
|
||||
subparser.add_argument(
|
||||
'--cdash-build',
|
||||
default=None,
|
||||
help=cdash_help['build']
|
||||
)
|
||||
subparser.add_argument(
|
||||
'--cdash-site',
|
||||
default=None,
|
||||
help=cdash_help['site']
|
||||
)
|
||||
|
||||
cdash_subgroup = subparser.add_mutually_exclusive_group()
|
||||
cdash_subgroup.add_argument(
|
||||
'--cdash-track',
|
||||
default='Experimental',
|
||||
help=cdash_help['track']
|
||||
)
|
||||
cdash_subgroup.add_argument(
|
||||
'--cdash-buildstamp',
|
||||
default=None,
|
||||
help=cdash_help['buildstamp']
|
||||
)
|
||||
|
||||
@@ -160,65 +160,8 @@ def setup_parser(subparser):
|
||||
action='store_true',
|
||||
help="Show usage instructions for CDash reporting"
|
||||
)
|
||||
subparser.add_argument(
|
||||
'-y', '--yes-to-all',
|
||||
action='store_true',
|
||||
dest='yes_to_all',
|
||||
help="""assume "yes" is the answer to every confirmation request.
|
||||
To run completely non-interactively, also specify '--no-checksum'."""
|
||||
)
|
||||
add_cdash_args(subparser, False)
|
||||
arguments.add_common_arguments(subparser, ['spec'])
|
||||
|
||||
|
||||
def add_cdash_args(subparser, add_help):
|
||||
cdash_help = {}
|
||||
if add_help:
|
||||
cdash_help['upload-url'] = "CDash URL where reports will be uploaded"
|
||||
cdash_help['build'] = """The name of the build that will be reported to CDash.
|
||||
Defaults to spec of the package to install."""
|
||||
cdash_help['site'] = """The site name that will be reported to CDash.
|
||||
Defaults to current system hostname."""
|
||||
cdash_help['track'] = """Results will be reported to this group on CDash.
|
||||
Defaults to Experimental."""
|
||||
cdash_help['buildstamp'] = """Instead of letting the CDash reporter prepare the
|
||||
buildstamp which, when combined with build name, site and project,
|
||||
uniquely identifies the build, provide this argument to identify
|
||||
the build yourself. Format: %%Y%%m%%d-%%H%%M-[cdash-track]"""
|
||||
else:
|
||||
cdash_help['upload-url'] = argparse.SUPPRESS
|
||||
cdash_help['build'] = argparse.SUPPRESS
|
||||
cdash_help['site'] = argparse.SUPPRESS
|
||||
cdash_help['track'] = argparse.SUPPRESS
|
||||
cdash_help['buildstamp'] = argparse.SUPPRESS
|
||||
|
||||
subparser.add_argument(
|
||||
'--cdash-upload-url',
|
||||
default=None,
|
||||
help=cdash_help['upload-url']
|
||||
)
|
||||
subparser.add_argument(
|
||||
'--cdash-build',
|
||||
default=None,
|
||||
help=cdash_help['build']
|
||||
)
|
||||
subparser.add_argument(
|
||||
'--cdash-site',
|
||||
default=None,
|
||||
help=cdash_help['site']
|
||||
)
|
||||
|
||||
cdash_subgroup = subparser.add_mutually_exclusive_group()
|
||||
cdash_subgroup.add_argument(
|
||||
'--cdash-track',
|
||||
default='Experimental',
|
||||
help=cdash_help['track']
|
||||
)
|
||||
cdash_subgroup.add_argument(
|
||||
'--cdash-buildstamp',
|
||||
default=None,
|
||||
help=cdash_help['buildstamp']
|
||||
)
|
||||
arguments.add_cdash_args(subparser, False)
|
||||
arguments.add_common_arguments(subparser, ['yes_to_all'])
|
||||
|
||||
|
||||
def default_log_file(spec):
|
||||
@@ -270,7 +213,7 @@ def install(parser, args, **kwargs):
|
||||
SPACK_CDASH_AUTH_TOKEN
|
||||
authentication token to present to CDash
|
||||
'''))
|
||||
add_cdash_args(parser, True)
|
||||
arguments.add_cdash_args(parser, True)
|
||||
parser.print_help()
|
||||
return
|
||||
|
||||
|
||||
@@ -6,11 +6,14 @@
|
||||
from __future__ import print_function
|
||||
import os
|
||||
import argparse
|
||||
import textwrap
|
||||
|
||||
import llnl.util.tty as tty
|
||||
|
||||
import spack.environment as ev
|
||||
import spack.cmd
|
||||
import spack.cmd.common.arguments as arguments
|
||||
import spack.report
|
||||
|
||||
description = "run spack's tests for an install"
|
||||
section = "administrator"
|
||||
@@ -18,50 +21,24 @@
|
||||
|
||||
|
||||
def setup_parser(subparser):
|
||||
# subparser.add_argument(
|
||||
# '--log-format',
|
||||
# default=None,
|
||||
# choices=spack.report.valid_formats,
|
||||
# help="format to be used for log files"
|
||||
# )
|
||||
# subparser.add_argument(
|
||||
# '--output-file',
|
||||
# default=None,
|
||||
# help="filename for the log file. if not passed a default will be used"
|
||||
# )
|
||||
# subparser.add_argument(
|
||||
# '--cdash-upload-url',
|
||||
# default=None,
|
||||
# help="CDash URL where reports will be uploaded"
|
||||
# )
|
||||
# subparser.add_argument(
|
||||
# '--cdash-build',
|
||||
# default=None,
|
||||
# help="""The name of the build that will be reported to CDash.
|
||||
# Defaults to spec of the package to install."""
|
||||
# )
|
||||
# subparser.add_argument(
|
||||
# '--cdash-site',
|
||||
# default=None,
|
||||
# help="""The site name that will be reported to CDash.
|
||||
# Defaults to current system hostname."""
|
||||
# )
|
||||
# cdash_subgroup = subparser.add_mutually_exclusive_group()
|
||||
# cdash_subgroup.add_argument(
|
||||
# '--cdash-track',
|
||||
# default='Experimental',
|
||||
# help="""Results will be reported to this group on CDash.
|
||||
# Defaults to Experimental."""
|
||||
# )
|
||||
# cdash_subgroup.add_argument(
|
||||
# '--cdash-buildstamp',
|
||||
# default=None,
|
||||
# help="""Instead of letting the CDash reporter prepare the
|
||||
# buildstamp which, when combined with build name, site and project,
|
||||
# uniquely identifies the build, provide this argument to identify
|
||||
# the build yourself. Format: %%Y%%m%%d-%%H%%M-[cdash-track]"""
|
||||
# )
|
||||
# arguments.add_common_arguments(subparser, ['yes_to_all'])
|
||||
subparser.add_argument(
|
||||
'--log-format',
|
||||
default=None,
|
||||
choices=spack.report.valid_formats,
|
||||
help="format to be used for log files"
|
||||
)
|
||||
subparser.add_argument(
|
||||
'--log-file',
|
||||
default=None,
|
||||
help="filename for the log file. if not passed a default will be used"
|
||||
)
|
||||
arguments.add_cdash_args(subparser, False)
|
||||
subparser.add_argument(
|
||||
'--help-cdash',
|
||||
action='store_true',
|
||||
help="Show usage instructions for CDash reporting"
|
||||
)
|
||||
|
||||
length_group = subparser.add_mutually_exclusive_group()
|
||||
length_group.add_argument(
|
||||
'--smoke', action='store_true', dest='smoke_test', default=True,
|
||||
@@ -76,6 +53,20 @@ def setup_parser(subparser):
|
||||
|
||||
|
||||
def test(parser, args):
|
||||
# cdash help option
|
||||
if args.help_cdash:
|
||||
parser = argparse.ArgumentParser(
|
||||
formatter_class=argparse.RawDescriptionHelpFormatter,
|
||||
epilog=textwrap.dedent('''\
|
||||
environment variables:
|
||||
SPACK_CDASH_AUTH_TOKEN
|
||||
authentication token to present to CDash
|
||||
'''))
|
||||
arguments.add_cdash_args(parser, True)
|
||||
parser.print_help()
|
||||
return
|
||||
|
||||
# Get specs to test
|
||||
env = ev.get_env(args, 'test')
|
||||
hashes = env.all_hashes() if env else None
|
||||
|
||||
@@ -87,11 +78,25 @@ def test(parser, args):
|
||||
tty.warn("No installed packages match spec %s" % spec)
|
||||
specs_to_test.extend(matching)
|
||||
|
||||
log_dir = os.getcwd()
|
||||
# Set up reporter
|
||||
setattr(args, 'package', [s.format() for s in specs_to_test])
|
||||
reporter = spack.report.collect_info(args.log_format, args)
|
||||
if not reporter.filename:
|
||||
if args.log_file:
|
||||
if os.path.isabs(args.log_file):
|
||||
log_file = args.log_file
|
||||
else:
|
||||
log_dir = os.getcwd()
|
||||
log_file = os.path.join(log_dir, args.log_file)
|
||||
else:
|
||||
log_file = os.path.join(os.getcwd(),
|
||||
'test-%s' % specs_to_test[0].dag_hash())
|
||||
reporter.filename = log_file
|
||||
reporter.specs = specs_to_test
|
||||
|
||||
if args.smoke_test:
|
||||
for spec in specs_to_test:
|
||||
log_file = os.path.join(log_dir, 'test-%s' % spec.dag_hash())
|
||||
spec.package.do_test(log_file)
|
||||
else:
|
||||
raise NotImplementedError
|
||||
with reporter:
|
||||
if args.smoke_test:
|
||||
for spec in specs_to_test:
|
||||
spec.package.do_test()
|
||||
else:
|
||||
raise NotImplementedError
|
||||
|
||||
@@ -1592,9 +1592,11 @@ def do_install(self, **kwargs):
|
||||
|
||||
do_install.__doc__ += install_args_docstring
|
||||
|
||||
def do_test(self, log_file, dirty=False):
|
||||
def do_test(self, dirty=False):
|
||||
def test_process():
|
||||
with log_output(log_file) as logger:
|
||||
test_log_file = os.path.join(
|
||||
os.getcwd(), 'test-%s' % self.spec.format('{name}-{hash:7}'))
|
||||
with log_output(test_log_file) as logger:
|
||||
with logger.force_echo():
|
||||
tty.msg('Testing package %s' %
|
||||
self.spec.format('{name}-{hash:7}'))
|
||||
|
||||
Reference in New Issue
Block a user