Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Handle Python test execution runtime errors #145

Merged
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,22 @@ def main() -> None:


def run_test(script_path: str, class_name: str, config: MatterTestConfig) -> None:
# For a script_path like 'custom/TC_XYZ' the module is 'custom.TC_XYZ'
module = importlib.import_module(script_path.replace("/", "."))
TestClassReference = getattr(module, class_name)

BaseManager.register(TestRunnerHooks.__name__)
manager = BaseManager(address=("0.0.0.0", 50000), authkey=b"abc")
manager.connect()
test_runner_hooks = manager.TestRunnerHooks() # shared object proxy # type: ignore

run_tests(TestClassReference, config, test_runner_hooks)
try:
# For a script_path like 'custom/TC_XYZ' the module is 'custom.TC_XYZ'
module = importlib.import_module(script_path.replace("/", "."))
TestClassReference = getattr(module, class_name)

run_tests(TestClassReference, config, test_runner_hooks)
except Exception as e:
test_runner_hooks.step_failure(
logger=None, logs=str(e), duration=0, request=None, received=None
)
test_runner_hooks.stop(duration=0)


def commission(config: MatterTestConfig) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ def step_success(self, logger: Any, logs: str, duration: int, request: Any) -> N
def step_failure(
self, logger: Any, logs: str, duration: int, request: Any, received: Any
) -> None:
self.mark_step_failure("Python test step failure")
failure_msg = "Python test step failure"
if logs:
failure_msg += f": {logs}"

self.mark_step_failure(failure_msg)

# Python tests with only 2 steps are the ones that don't follow the template.
# In the case of a test file with multiple test cases, more than one of these
Expand Down
Loading