25.01.2021 21:50, Vladimir Sementsov-Ogievskiy wrote:
Add TestRunner class, which will run tests in a new python iotests
running framework.
There are some differences with current ./check behavior, most
significant are:
- Consider all tests self-executable, just run them, don't run python
by hand.
- Elapsed time is cached in json file
- Elapsed time precision increased a bit
- Instead of using "diff -w" which ignores all whitespace differences,
manually strip whitespace at line end then use python difflib, which
no longer ignores spacing mid-line
Signed-off-by: Vladimir Sementsov-Ogievskiy<[email protected]>
squash-in to fix mypy complains, and try use ContextManager for CI:
diff --git a/tests/qemu-iotests/testrunner.py b/tests/qemu-iotests/testrunner.py
index 8480d2d586..046f9ce38f 100644
--- a/tests/qemu-iotests/testrunner.py
+++ b/tests/qemu-iotests/testrunner.py
@@ -27,8 +27,8 @@ import json
import termios
import sys
from contextlib import contextmanager
-from contextlib import AbstractContextManager
-from typing import List, Optional, Iterator, Any, Sequence
+from typing import List, Optional, Iterator, Any, Sequence, Dict, \
+ ContextManager
from testenv import TestEnv
@@ -69,7 +69,7 @@ def savetty() -> Iterator[None]:
termios.tcsetattr(fd, termios.TCSADRAIN, attr)
-class LastElapsedTime(AbstractContextManager['LastElapsedTime']):
+class LastElapsedTime(ContextManager['LastElapsedTime']):
""" Cache for elapsed time for tests, to show it during new test run
It is safe to use get() at any time. To use update(), you must either
@@ -78,6 +78,7 @@ class
LastElapsedTime(AbstractContextManager['LastElapsedTime']):
def __init__(self, cache_file: str, env: TestEnv) -> None:
self.env = env
self.cache_file = cache_file
+ self.cache: Dict[str, Dict[str, Dict[str, float]]]
try:
with open(cache_file) as f:
@@ -98,8 +99,7 @@ class
LastElapsedTime(AbstractContextManager['LastElapsedTime']):
def update(self, test: str, elapsed: float) -> None:
d = self.cache.setdefault(test, {})
- d = d.setdefault(self.env.imgproto, {})
- d[self.env.imgfmt] = elapsed
+ d.setdefault(self.env.imgproto, {})[self.env.imgfmt] = elapsed
def save(self) -> None:
with open(self.cache_file, 'w') as f:
@@ -124,7 +124,7 @@ class TestResult:
self.interrupted = interrupted
-class TestRunner(AbstractContextManager['TestRunner']):
+class TestRunner(ContextManager['TestRunner']):
def __init__(self, env: TestEnv, makecheck: bool = False,
color: str = 'auto') -> None:
self.env = env
--
Best regards,
Vladimir