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 <ps@pks.im>
This commit is contained in:
parent
23a9a25779
commit
4526a75e25
|
@ -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]
|
||||
|
|
Loading…
Reference in New Issue