Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion lib/pavilion/commands/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,13 @@ def run(self, pav_cfg, args):
else:
if TestID.is_valid_id(args.id):
args.id = TestID(args.id)
else:
elif SeriesID.is_valid_id(args.id):
args.id = SeriesID(args.id)
else:
output.fprint(self.errfile,
"Invalid test or series id: {}".format(args.id),
color=output.RED)
return 1

if cmd_name == 'states':
if args.id == SeriesID("last"):
Expand Down
15 changes: 15 additions & 0 deletions test/tests/log_cmd_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,21 @@ def test_follow(self):
self.assertIn('output', out)
log_cmd.follow_testing = True

def test_log_invalid_id(self):
"""Invalid IDs should fail gracefully without an uncaught ValueError."""

log_cmd = commands.get_command('log')
log_cmd.silence()

parser = argparse.ArgumentParser()
log_cmd._setup_arguments(parser)

args = parser.parse_args(['run', 'not-a-real-id'])
result = log_cmd.run(self.pav_cfg, args)
self.assertEqual(result, 1)
_, err = log_cmd.clear_output()
self.assertIn('Invalid test or series id', err)

def test_log_states(self):
"""Test the 'log states' command."""

Expand Down