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

Add install test show (logs) command

parent 93e2810a
No related branches found
No related tags found
No related merge requests found
...@@ -239,6 +239,41 @@ def die(message, *args, **kwargs): ...@@ -239,6 +239,41 @@ def die(message, *args, **kwargs):
sys.exit(1) sys.exit(1)
def get_answer(prompt, **kwargs):
options = kwargs.get('options', [])
default = kwargs.get('default', None)
abort = kwargs.get('abort', None)
explain = ''
if default is not None:
assert default in options
explain += 'default is \'{0}\''.format(default)
if abort is not None:
if explain:
explain += ', '
explain += '\'{0}\' to abort'.format(abort)
if explain:
prompt = '{0} ({1}) '.format(prompt, explain)
val = None
while val is None:
msg(prompt, newline=False)
ans = input()
if ans == abort:
return None
if ans:
if ans in options:
val = ans
else:
msg('Please enter one of: {0}'.format(', '.join(options)))
elif default is not None:
val = default
return val
def get_number(prompt, **kwargs): def get_number(prompt, **kwargs):
default = kwargs.get('default', None) default = kwargs.get('default', None)
abort = kwargs.get('abort', None) abort = kwargs.get('abort', None)
......
...@@ -92,6 +92,12 @@ def setup_parser(subparser): ...@@ -92,6 +92,12 @@ def setup_parser(subparser):
'filter', nargs=argparse.REMAINDER, 'filter', nargs=argparse.REMAINDER,
help='optional case-insensitive glob patterns to filter results.') help='optional case-insensitive glob patterns to filter results.')
# Show
show_parser = sp.add_parser('show', help=test_show.__doc__)
show_parser.add_argument(
'names', nargs=argparse.REMAINDER,
help="Test suites for which to show test logs")
# Status # Status
status_parser = sp.add_parser('status', help=test_status.__doc__) status_parser = sp.add_parser('status', help=test_status.__doc__)
status_parser.add_argument( status_parser.add_argument(
...@@ -219,6 +225,42 @@ def match(t, f): ...@@ -219,6 +225,42 @@ def match(t, f):
tty.msg(msg) tty.msg(msg)
def test_show(args):
"""Provide ability to view test logs for particular Spack test suites."""
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)
else:
test_suites = spack.install_test.get_all_test_suites()
if not test_suites:
tty.msg("No test suites with status to report")
for test_suite in test_suites:
for spec in test_suite.specs:
log_file = test_suite.log_file_for_spec(spec)
if os.path.exists(log_file):
filename = os.path.basename(log_file)
msg = 'Show {0}?\n\t'.format(filename)
answer = tty.get_answer(msg, options=['y', 'n', 'q'],
default='y', abort='q')
if not answer:
tty.msg('Aborting show of test suite logs')
return
if answer == 'y':
with open(log_file, 'r') as ifd:
lines = ifd.readlines()
for ln in lines:
print(ln.strip())
print() # Add a blank line for readability if multiple
def test_status(args): def test_status(args):
"""Get the current status for a particular Spack test suites.""" """Get the current status for a particular Spack test suites."""
if args.names: if args.names:
...@@ -307,5 +349,6 @@ def test_remove(args): ...@@ -307,5 +349,6 @@ def test_remove(args):
for test_suite in test_suites: for test_suite in test_suites:
shutil.rmtree(test_suite.stage) shutil.rmtree(test_suite.stage)
def test(parser, args): def test(parser, args):
globals()['test_%s' % args.test_command](args) globals()['test_%s' % args.test_command](args)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment