Skip to content

Commit

Permalink
tests: Add fallback log directory for custom_log.py
Browse files Browse the repository at this point in the history
Reviewed-by: Anuj Borah <[email protected]>
  • Loading branch information
jakub-vavra-cz committed Jul 29, 2024
1 parent 7c83a76 commit fc000fa
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/tests/multihost/sssd/testlib/common/custom_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ def _write_log(self, test: str, phases: list = None) -> None:
test_name = test.split("::")[-1]
test_name = test_name.translate(
str.maketrans('":<>|*? [/', "----------", "]()"))
logdir = os.path.join(os.path.dirname(self.config.option.log_file),
'logs')
if self.config.option.log_file:
logdir = os.path.join(os.path.dirname(self.config.option.log_file), 'logs')
else:
logdir = os.path.join(os.getcwd(), 'logs')
os.makedirs(logdir, exist_ok=True)
logpath = os.path.join(logdir, f'{test_name}.log')
with open(logpath, 'a+') as f:
Expand Down

0 comments on commit fc000fa

Please sign in to comment.