From 4526a75e25c8f4e908e6c142cf6658bac0acb5e3 Mon Sep 17 00:00:00 2001 From: Patrick Steinhardt Date: Thu, 2 Jan 2025 11:42:17 +0100 Subject: mtest: move `console_mode` property into TestRun class Move the `console_mode` property into the TestRun Class. This will be required by a subsequent commit where we start to ignore test results for parsed interactive tests. Signed-off-by: Patrick Steinhardt --- mesonbuild/mtest.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index cd5c5f100..8e490d5ff 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -948,7 +948,8 @@ class TestRun: return super().__new__(TestRun.PROTOCOL_TO_CLASS[test.protocol]) def __init__(self, test: TestSerialisation, test_env: T.Dict[str, str], - name: str, timeout: T.Optional[int], is_parallel: bool, verbose: bool): + name: str, timeout: T.Optional[int], is_parallel: bool, verbose: bool, + interactive: bool): self.res = TestResult.PENDING self.test = test self._num: T.Optional[int] = None @@ -968,6 +969,7 @@ class TestRun: self.junit: T.Optional[et.ElementTree] = None self.is_parallel = is_parallel self.verbose = verbose + self.interactive = interactive self.warnings: T.List[str] = [] def start(self, cmd: T.List[str]) -> None: @@ -982,6 +984,15 @@ class TestRun: self._num = TestRun.TEST_NUM return self._num + @property + def console_mode(self) -> ConsoleUser: + if self.interactive: + return ConsoleUser.INTERACTIVE + elif self.direct_stdout: + return ConsoleUser.STDOUT + else: + return ConsoleUser.LOGGER + @property def direct_stdout(self) -> bool: return self.verbose and not self.is_parallel and not self.needs_parsing @@ -1474,14 +1485,11 @@ class SingleTestRunner: is_parallel = test.is_parallel and self.options.num_processes > 1 and not self.options.interactive verbose = (test.verbose or self.options.verbose) and not self.options.quiet - self.runobj = TestRun(test, env, name, timeout, is_parallel, verbose) + self.runobj = TestRun(test, env, name, timeout, is_parallel, verbose, self.options.interactive) - if self.options.interactive: - self.console_mode = ConsoleUser.INTERACTIVE - elif self.runobj.direct_stdout: - self.console_mode = ConsoleUser.STDOUT - else: - self.console_mode = ConsoleUser.LOGGER + @property + def console_mode(self) -> ConsoleUser: + return self.runobj.console_mode def _get_test_cmd(self) -> T.Optional[T.List[str]]: testentry = self.test.fname[0] -- cgit v1.2.3