Skip to content

Commit 9563a51

Browse files
DeborahOlaboyeSamWilsn
authored andcommitted
chore(test): don't write logs to repo root
1 parent e1f2df6 commit 9563a51

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

packages/testing/src/execution_testing/cli/pytest_commands/plugins/custom_logging/plugin_logging.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ def pytest_addoption(parser: pytest.Parser) -> None: # noqa: D103
5959
"CRITICAL, default - INFO. An integer in [0, 50] may be also provided."
6060
),
6161
)
62+
logging_group.addoption(
63+
"--log-to",
64+
action="store",
65+
default=None,
66+
dest="eest_log_dir",
67+
help="Directory to write log files. Defaults to ./logs if not specified.",
68+
)
6269

6370

6471
@functools.cache
@@ -108,9 +115,10 @@ def pytest_configure(config: pytest.Config) -> None:
108115

109116
worker_id = os.getenv("PYTEST_XDIST_WORKER", "main")
110117
log_filename = f"{log_stem}-{worker_id}.log"
111-
log_path = Path("logs")
112-
log_path.mkdir(exist_ok=True)
113-
log_file_path = log_path / log_filename
118+
log_dir = getattr(config.option, "eest_log_dir", None)
119+
base_logs_dir = Path("logs") if log_dir is None else Path(log_dir)
120+
base_logs_dir.mkdir(parents=True, exist_ok=True)
121+
log_file_path = base_logs_dir / log_filename
114122

115123
# Store the log file path in the pytest config
116124
config.option.eest_log_file_path = log_file_path

tox.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ commands =
6565
-m "not slow and not zkevm and not benchmark" \
6666
-n auto --maxprocesses 10 --dist=loadgroup \
6767
--basetemp="{temp_dir}/pytest" \
68+
--log-to "{toxworkdir}/logs" \
6869
--clean \
6970
--until Osaka \
7071
tests
@@ -86,6 +87,7 @@ commands =
8687
-m "not slow and not zkevm and not benchmark" \
8788
-n auto --maxprocesses 7 --dist=loadgroup \
8889
--basetemp="{temp_dir}/pytest" \
90+
--log-to "{toxworkdir}/logs" \
8991
--clean \
9092
--until Osaka \
9193
tests

0 commit comments

Comments
 (0)