Skip to content

Commit

Permalink
Fix work dir propagation
Browse files Browse the repository at this point in the history
  • Loading branch information
TJ Bruno committed Mar 29, 2023
1 parent c037e62 commit a4be5d8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/changelog/2933.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix issue where ``work_dir`` was not correctly including ``tox_root`` for test runs
4 changes: 3 additions & 1 deletion src/tox/config/sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ def register_config(self) -> None:
)

def work_dir_builder(conf: Config, env_name: str | None) -> Path: # noqa: U100
return (conf.work_dir if conf.work_dir is not None else cast(Path, self["tox_root"])) / ".tox"
if conf.work_dir == conf.src_path.parent:
return cast(Path, self["tox_root"]) / ".tox"
return conf.work_dir

def work_dir_post_process(value: Path) -> Path:
return self._conf.work_dir if self._conf.options.work_dir else value
Expand Down
8 changes: 8 additions & 0 deletions tests/config/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@ def test_relative_config_paths_resolve(tox_project: ToxProjectCreator) -> None:
result.assert_success()
expected = f"[testenv:py]\nchange_dir = {project.path}\nenv_dir = {project.path / '.tox' / 'py'}\n"
assert result.out == expected


def test_tox_root_propagates_to_work_dir(tox_project: ToxProjectCreator) -> None:
root_dir = "root"
project = tox_project({"tox.ini": "[tox]"})
result = project.run("c", "--root", root_dir)
result.assert_success()
assert result.state.conf.core["work_dir"].parent.name == root_dir

0 comments on commit a4be5d8

Please sign in to comment.