Benchmark Tests: improve error reporting.
When a benchmark test was failing, there was very little info available to investigate it. Now report the stdout/stderr generated by the failing command.
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
from .environment import TestEnvironment
|
||||
from .environment import TestFailure, TestEnvironment
|
||||
from .device import TestDevice, TestMachine
|
||||
from .config import TestEntry, TestQueue, TestConfig
|
||||
from .test import Test, TestCollection
|
||||
|
||||
@@ -31,7 +31,10 @@ class TestEntry:
|
||||
device_id: str = 'CPU'
|
||||
device_name: str = 'Unknown CPU'
|
||||
status: str = 'queued'
|
||||
# Short, single-line error.
|
||||
error_msg: str = ''
|
||||
# More detailed error info, potentially multi-lines.
|
||||
exception_msg: str = ''
|
||||
output: dict = field(default_factory=dict)
|
||||
benchmark_type: str = 'comparison'
|
||||
|
||||
|
||||
@@ -21,6 +21,20 @@ from .config import TestConfig
|
||||
from .device import TestMachine
|
||||
|
||||
|
||||
class TestFailure(Exception):
|
||||
def __init__(self, *args, message, output_lines=[], **kwargs):
|
||||
super().__init__(message, *args)
|
||||
self.message = message
|
||||
self.output_lines = output_lines
|
||||
|
||||
def __str__(self):
|
||||
msg = self.message
|
||||
if self.output_lines:
|
||||
msg += f":\n{'': <10} | "
|
||||
msg += f"\n{'': <10} | ".join(l.rstrip(' \r\n\t') for l in self.output_lines)
|
||||
return msg
|
||||
|
||||
|
||||
class TestEnvironment:
|
||||
def __init__(self, blender_git_dir: pathlib.Path, base_dir: pathlib.Path):
|
||||
self.blender_git_dir = blender_git_dir
|
||||
@@ -223,7 +237,7 @@ class TestEnvironment:
|
||||
|
||||
# Raise error on failure
|
||||
if proc.returncode != 0 and not silent:
|
||||
raise Exception("Error executing command")
|
||||
raise TestFailure(message="Error executing command", output_lines=lines)
|
||||
|
||||
return lines
|
||||
|
||||
|
||||
Reference in New Issue
Block a user