nixos/tests: improve get_unit_info expressiveness on failure

This commit is contained in:
Marijan Petricevic 2019-11-08 10:46:37 +01:00
parent b937c4c734
commit 5854aaf680

View File

@ -319,7 +319,11 @@ class Machine:
def get_unit_info(self, unit, user=None):
status, lines = self.systemctl('--no-pager show "{}"'.format(unit), user)
if status != 0:
return None
raise Exception(
'retrieving systemctl info for unit "{}" {} failed with exit code {}'.format(
unit, "" if user is None else 'under user "{}"'.format(user), status
)
)
line_pattern = re.compile(r"^([^=]+)=(.*)$")