about summary refs log tree commit diff
path: root/nixos/lib/test-driver
diff options
context:
space:
mode:
authorStefan Hertrampf <stefan.hertrampf@cyberus-technology.de>2024-04-05 08:42:30 +0200
committerStefan Hertrampf <stefan.hertrampf@cyberus-technology.de>2024-04-22 13:35:24 +0200
commit0d015895debd63b937f1b3ee10cb3a73aa180a8f (patch)
tree3a9ebfac0fc432926d494d5d6c9b5629d99311c6 /nixos/lib/test-driver
parentee1428c6543df8ad9f497af343fad8ac6be1d900 (diff)
nixos/test-driver: separate the subtest log call
We do not use the generic "nested" function but introduce a separate
subtest log call. This will later allow us to track subtests and account
logs to specific subtests.
Diffstat (limited to 'nixos/lib/test-driver')
-rw-r--r--nixos/lib/test-driver/test_driver/driver.py2
-rw-r--r--nixos/lib/test-driver/test_driver/logger.py5
2 files changed, 6 insertions, 1 deletions
diff --git a/nixos/lib/test-driver/test_driver/driver.py b/nixos/lib/test-driver/test_driver/driver.py
index f792c04591996..7dfbfdcf1c2aa 100644
--- a/nixos/lib/test-driver/test_driver/driver.py
+++ b/nixos/lib/test-driver/test_driver/driver.py
@@ -99,7 +99,7 @@ class Driver:
 
     def subtest(self, name: str) -> Iterator[None]:
         """Group logs under a given test name"""
-        with rootlog.nested("subtest: " + name):
+        with rootlog.subtest(name):
             try:
                 yield
                 return True
diff --git a/nixos/lib/test-driver/test_driver/logger.py b/nixos/lib/test-driver/test_driver/logger.py
index 0b0623bddfa1e..1b802f992f640 100644
--- a/nixos/lib/test-driver/test_driver/logger.py
+++ b/nixos/lib/test-driver/test_driver/logger.py
@@ -80,6 +80,11 @@ class Logger:
             pass
 
     @contextmanager
+    def subtest(self, name: str, attributes: Dict[str, str] = {}) -> Iterator[None]:
+        with self.nested("subtest: " + name, attributes):
+            yield
+
+    @contextmanager
     def nested(self, message: str, attributes: Dict[str, str] = {}) -> Iterator[None]:
         self._eprint(
             self.maybe_prefix(