diff --git a/avocado/plugins/jobs.py b/avocado/plugins/jobs.py index c1b5fa8381..2edb2e5f06 100644 --- a/avocado/plugins/jobs.py +++ b/avocado/plugins/jobs.py @@ -55,15 +55,33 @@ def _print_job_tests(tests): date_fmt = "%Y/%m/%d %H:%M:%S" for test in tests: status = test.get("status") + if status is None: + raise ValueError("Test status is missing - corrupted test data") + decorator = output.TEST_STATUS_DECORATOR_MAPPING.get(status) - # Retrieve "end" for backward compatibility - end = datetime.fromtimestamp(test.get("actual_end", test.get("end"))) + if decorator is None: + raise ValueError( + f"Unknown test status '{status}' - corrupted test data" + ) + + end_timestamp = test.get("actual_end", test.get("end")) + if end_timestamp is not None: + end = datetime.fromtimestamp(end_timestamp).strftime(date_fmt) + else: + end = "" + + time_taken = test.get("time") + if time_taken is not None: + time_str = f"{float(time_taken):5f}" + else: + time_str = "" + test_matrix.append( ( - test.get("id"), - end.strftime(date_fmt), - f"{float(test.get('time')):5f}", - decorator(status, ""), + test.get("id", ""), + end, + time_str, + decorator(status, "") if decorator else "", ) ) header = ( @@ -118,13 +136,13 @@ def handle_list_command(jobs_results): job = json.load(fp) LOG_UI.info( "%-40s %-26s %3s (%s/%s/%s/%s)", - job["job_id"], - job["start"], - job["total"], - job["pass"], - job["skip"], - job["errors"], - job["failures"], + job.get("job_id", "N/A"), + job.get("start", "N/A"), + job.get("total", "N/A"), + job.get("pass", "N/A"), + job.get("skip", "N/A"), + job.get("errors", "N/A"), + job.get("failures", "N/A"), ) return exit_codes.AVOCADO_ALL_OK