Skip to content
Snippets Groups Projects
Commit 8878c11c authored by Tamara Dahlgren's avatar Tamara Dahlgren
Browse files

Added test results filter and log display support

parent 3f4dd14f
Branches
No related tags found
No related merge requests found
......@@ -101,8 +101,13 @@ def setup_parser(subparser):
# Results
results_parser = sp.add_parser('results', help=test_results.__doc__)
results_parser.add_argument(
'names', nargs=argparse.REMAINDER,
help="Test suites for which to print results")
'-l', '--logs', action='store_true',
help="print the test log for each matching package")
results_parser.add_argument(
'-f', '--failed', action='store_true',
help="only show results for failed tests")
arguments.add_common_arguments(results_parser, ['constraint'])
# Remove
remove_parser = sp.add_parser('remove', help=test_remove.__doc__)
......@@ -240,37 +245,67 @@ def test_status(args):
tty.msg("Test suite %s completed" % test_suite.name)
def _report_suite_results(test_suite, args):
"""Report the relevant test suite results."""
# TODO: Make this handle capability tests too
# The results file may turn out to be a placeholder for future work
specs = args.specs()
test_specs = {test_suite.test_pkg_id(s): s for s in test_suite.specs
if s in specs}
if not test_specs:
return
if os.path.exists(test_suite.results_file):
results_desc = 'Failing results' if args.failed else 'Results'
matching = ", spec matching '{0}'".format(' '.join(args.constraint)) \
if args.constraint else ''
tty.msg("{0} for test suite '{1}'{2}:"
.format(results_desc, test_suite.name, matching))
results = {}
with open(test_suite.results_file, 'r') as f:
for line in f:
pkg_id, status = line.split()
results[pkg_id] = status
for pkg_id in test_specs:
if pkg_id in results:
status = results[pkg_id]
if args.failed and status != 'FAILED':
continue
msg = " {0} {1}".format(pkg_id, status)
if args.logs:
spec = test_specs[pkg_id]
log_file = test_suite.log_file_for_spec(spec)
if os.path.isfile(log_file):
with open(log_file, 'r') as f:
msg += '\n{0}'.format(''.join(f.readlines()))
tty.msg(msg)
else:
msg = "Test %s has no results.\n" % test_suite.name
msg += " Check if it is running with "
msg += "`spack test status %s`" % test_suite.name
tty.msg(msg)
def test_results(args):
"""Get the results from Spack test suites (default all)."""
if args.names:
test_suites = []
for name in args.names:
test_suite = spack.install_test.get_test_suite(name)
if test_suite:
test_suites.append(test_suite)
else:
tty.msg("No test suite %s found in test stage" % name)
name = ''
if args.constraint and ':' in args.constraint[0]:
name, args.constraint[0] = args.constraint[0].split(':')
if name:
test_suites = [spack.install_test.get_test_suite(name)]
if not test_suites:
tty.msg("No test suite {0} found in test stage".format(name))
else:
test_suites = spack.install_test.get_all_test_suites()
if not test_suites:
tty.msg("No test suites with results to report")
# TODO: Make this handle capability tests too
# The results file may turn out to be a placeholder for future work
for test_suite in test_suites:
results_file = test_suite.results_file
if os.path.exists(results_file):
msg = "Results for test suite %s: \n" % test_suite.name
with open(results_file, 'r') as f:
lines = f.readlines()
for line in lines:
msg += " %s" % line
tty.msg(msg)
else:
msg = "Test %s has no results.\n" % test_suite.name
msg += " Check if it is running with "
msg += "`spack test status %s`" % test_suite.name
tty.msg(msg)
_report_suite_results(test_suite, args)
def test_remove(args):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment