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

Show python logs at the end of the test execution #41

Merged
merged 4 commits into from
Dec 11, 2023
Merged
Changes from 1 commit
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 @@ -16,7 +16,7 @@
import re
from asyncio import sleep
from multiprocessing.managers import BaseManager
from typing import Any, Type, TypeVar
from typing import Any, Generator, Type, TypeVar, cast

from app.models import TestCaseExecution
from app.test_engine.logger import test_engine_logger as logger
Expand All @@ -31,7 +31,12 @@
SDKPythonTestResultBase,
SDKPythonTestRunnerHooks,
)
from .utils import EXECUTABLE, RUNNER_CLASS_PATH, generate_command_arguments
from .utils import (
EXECUTABLE,
RUNNER_CLASS_PATH,
generate_command_arguments,
handle_logs,
)

# Custom type variable used to annotate the factory method in PythonTestCase.
T = TypeVar("T", bound="PythonTestCase")
Expand Down Expand Up @@ -172,13 +177,12 @@ async def execute(self) -> None:
if self.chip_tool.pics_file_created:
command.append(f" --PICS {PICS_FILE_PATH}")

# TODO Ignoring stream from docker execution
self.chip_tool.send_command(
exec_result = self.chip_tool.send_command(
command,
prefix=EXECUTABLE,
is_stream=True,
is_socket=False,
).output
)

while ((update := test_runner_hooks.update_test()) is not None) or (
not test_runner_hooks.is_finished()
Expand All @@ -189,6 +193,11 @@ async def execute(self) -> None:

self.__handle_update(update)

# Step: Show test logs
self.next_step()
logger.info("---- Start of Python test logs ----")
handle_logs(cast(Generator, exec_result.output), logger)
logger.info("---- End of Python test logs ----")
finally:
pass

Expand All @@ -208,3 +217,4 @@ def create_test_steps(self) -> None:
for step in self.python_test.steps:
python_test_step = TestStep(step.label)
self.test_steps.append(python_test_step)
self.test_steps.append(TestStep("Show test logs"))
Loading