diff --git a/avocado/plugins/jobs.py b/avocado/plugins/jobs.py index c1b5fa8381..af18168795 100644 --- a/avocado/plugins/jobs.py +++ b/avocado/plugins/jobs.py @@ -56,14 +56,25 @@ def _print_job_tests(tests): for test in tests: status = test.get("status") decorator = output.TEST_STATUS_DECORATOR_MAPPING.get(status) - # Retrieve "end" for backward compatibility - end = datetime.fromtimestamp(test.get("actual_end", test.get("end"))) + + 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 = "N/A" + + time_taken = test.get("time") + if time_taken is not None: + time_str = f"{float(time_taken):5f}" + else: + time_str = "N/A" + test_matrix.append( ( - test.get("id"), - end.strftime(date_fmt), - f"{float(test.get('time')):5f}", - decorator(status, ""), + test.get("id", "N/A"), + end, + time_str, + decorator(status, "") if decorator else "N/A", ) ) header = ( @@ -116,15 +127,24 @@ def handle_list_command(jobs_results): for filename in jobs_results.values(): with open(filename, "r", encoding="utf-8") as fp: job = json.load(fp) + + job_id = job.get("job_id", "N/A") + start_time = job.get("start", "N/A") + total_tests = job.get("total", "N/A") + passed = job.get("pass", "N/A") + skipped = job.get("skip", "N/A") + errors = job.get("errors", "N/A") + failures = job.get("failures", "N/A") + 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_id, + start_time, + total_tests, + passed, + skipped, + errors, + failures, ) return exit_codes.AVOCADO_ALL_OK