3
0
Fork 0
forked from mirrors/nixpkgs

Merge pull request #168609 from rnhmjoj/pr-test-driver

nixos/test-driver: highlight driver log lines
This commit is contained in:
Jacek Galowicz 2022-04-14 13:09:36 +02:00 committed by GitHub
commit 6b414c5b66
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 3 deletions

View file

@ -86,7 +86,7 @@ class Driver:
def subtest(self, name: str) -> Iterator[None]: def subtest(self, name: str) -> Iterator[None]:
"""Group logs under a given test name""" """Group logs under a given test name"""
with rootlog.nested(name): with rootlog.nested("subtest: " + name):
try: try:
yield yield
return True return True

View file

@ -1,4 +1,4 @@
from colorama import Style from colorama import Style, Fore
from contextlib import contextmanager from contextlib import contextmanager
from typing import Any, Dict, Iterator from typing import Any, Dict, Iterator
from queue import Queue, Empty from queue import Queue, Empty
@ -81,7 +81,11 @@ class Logger:
@contextmanager @contextmanager
def nested(self, message: str, attributes: Dict[str, str] = {}) -> Iterator[None]: def nested(self, message: str, attributes: Dict[str, str] = {}) -> Iterator[None]:
self._eprint(self.maybe_prefix(message, attributes)) self._eprint(
self.maybe_prefix(
Style.BRIGHT + Fore.GREEN + message + Style.RESET_ALL, attributes
)
)
self.xml.startElement("nest", attrs={}) self.xml.startElement("nest", attrs={})
self.xml.startElement("head", attributes) self.xml.startElement("head", attributes)