Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tox_root propagation to work_dir #2962

Merged
merged 14 commits into from Apr 5, 2023
Merged

Fix tox_root propagation to work_dir #2962

merged 14 commits into from Apr 5, 2023

Conversation

Tbruno25
Copy link
Contributor

This applies a fix for issue #2933 where work_dir was not accurately including the current tox_root during test runs

Thanks for contribution

Please, make sure you address all the checklists (for details on how see
development documentation)!

  • ran the linter to address style issues (tox -e fix)
  • wrote descriptive pull request text
  • ensured there are test(s) validating the fix
  • added news fragment in docs/changelog folder
  • updated/extended the documentation

@Tbruno25 Tbruno25 changed the title Fix tox_root propagation to work_dir Draft: Fix tox_root propagation to work_dir Mar 29, 2023
@Tbruno25 Tbruno25 changed the title Draft: Fix tox_root propagation to work_dir Fix tox_root propagation to work_dir Mar 29, 2023
@Tbruno25 Tbruno25 marked this pull request as draft March 29, 2023 20:13
@kdestin
Copy link
Contributor

kdestin commented Mar 30, 2023

Ah, I probably should've mentioned in the issue that I was working on this.

Here's what I have so far: c037e62...kdestin:tox:2d2f0d54922e126a275fec4ecec805ebdcae67de

Let me know if you'd like me to open a PR onto your branch, to incorporate these changes.


The only notable differences are:

  • I just ripped out the true branch of

     (conf.work_dir if conf.work_dir is not None else cast(Path, self["tox_root"])) / ".tox"

    I may be wrong, but my understanding of the control flow is that the conf.work_dir can never actually be None. In Config.make, it's always set to a non-None value:

    root: Path = source.path.parent if parsed.root_dir is None else parsed.root_dir
    work_dir: Path = source.path.parent if parsed.work_dir is None else parsed.work_dir

    And the true branch doesn't seem like it's needed:

    • The default case gets handled by returning case(Path, self["tox_root"])) / ".tox"
    • The case when work_dir is set by --workdir is handled here:

    tox/src/tox/config/sets.py

    Lines 196 to 197 in a4be5d8

    def work_dir_post_process(value: Path) -> Path:
    return self._conf.work_dir if self._conf.options.work_dir else value

  • I wrote tests in tests/test_run.py (instead of tests/test_main.py), since there was already a test for --workdir there which would've been similar to the test of --root.

  • I believe I have some fixes for some of your test failures

Copy link
Member

@gaborbernat gaborbernat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CI is failing.

@Tbruno25
Copy link
Contributor Author

Let me know if you'd like me to open a PR onto your branch, to incorporate these changes.

Let's merge it in!

I may be wrong, but my understanding of the control flow is that the conf.work_dir can never actually be None. In Config.make, it's always set to a non-None value:
...

  • The default case gets handled by returning case(Path, self["tox_root"])) / ".tox"
  • The case when work_dir is set by --workdir is handled here:

Agree with your conclusion.

tox/src/tox/config/sets.py

Lines 196 to 197 in a4be5d8

def work_dir_post_process(value: Path) -> Path:
return self._conf.work_dir if self._conf.options.work_dir else value

  • I wrote tests in tests/test_run.py (instead of tests/test_main.py), since there was already a test for --workdir there which would've been similar to the test of --root.
  • I believe I have some fixes for some of your test failures

I was really hoping to avoid altering existing tests which is why I was "guess and checking" with the different fixes. If you've already re-worked these then even more reason to pull it in 👍

@Tbruno25 Tbruno25 marked this pull request as ready for review March 30, 2023 17:58
@Tbruno25
Copy link
Contributor Author

CI is failing.

Should be all set thanks to @kdestin 🚀

src/tox/config/sets.py Outdated Show resolved Hide resolved
src/tox/config/sets.py Outdated Show resolved Hide resolved
tests/tox_env/python/test_python_runner.py Show resolved Hide resolved
@gaborbernat gaborbernat merged commit 52cbe9a into tox-dev:main Apr 5, 2023
24 of 25 checks passed
@Tbruno25 Tbruno25 deleted the tj/bugfix-2933 branch April 5, 2023 17:17
descope bot added a commit to descope/django-descope that referenced this pull request Jun 11, 2023
This PR contains the following updates:

| Package | Type | Update | Change | Pending |
|---|---|---|---|---|
| [tox](https://togithub.com/tox-dev/tox)
([changelog](https://tox.wiki/en/latest/changelog.html)) | dev | minor |
`4.4.8` -> `4.5.1` | `4.6.0` (+1) |

---

### Release Notes

<details>
<summary>tox-dev/tox</summary>

### [`v4.5.1`](https://togithub.com/tox-dev/tox/releases/tag/4.5.1):
Test Trusted Publisher

[Compare Source](https://togithub.com/tox-dev/tox/compare/4.5.0...4.5.1)

### [`v4.5.0`](https://togithub.com/tox-dev/tox/releases/tag/4.5.0)

[Compare
Source](https://togithub.com/tox-dev/tox/compare/4.4.12...4.5.0)

#### What's Changed

- Bump deps and tools by
[@&#8203;gaborbernat](https://togithub.com/gaborbernat) in
[tox-dev/tox#2987
- git: Ignore the .lock file for demo_pkg_inline by
[@&#8203;hroncok](https://togithub.com/hroncok) in
[tox-dev/tox#2988
- Add FAQ entry on how to test against EOL Python versions by
[@&#8203;jugmac00](https://togithub.com/jugmac00) in
[tox-dev/tox#2991
- Feature: suppress step timings for verbosity=1
[#&#8203;2891](https://togithub.com/tox-dev/tox/issues/2891) by
[@&#8203;nedbat](https://togithub.com/nedbat) in
[tox-dev/tox#2992

**Full Changelog**:
tox-dev/tox@4.4.12...4.5.0

### [`v4.4.12`](https://togithub.com/tox-dev/tox/releases/tag/4.4.12)

[Compare
Source](https://togithub.com/tox-dev/tox/compare/4.4.11...4.4.12)

#### What's Changed

- Avoid race conditions in tests using the demo_pkg_inline fixture by
[@&#8203;hroncok](https://togithub.com/hroncok) in
[tox-dev/tox#2986
- Bump deps and tools by
[@&#8203;gaborbernat](https://togithub.com/gaborbernat) in
[tox-dev/tox#2981

**Full Changelog**:
tox-dev/tox@4.4.11...4.4.12

### [`v4.4.11`](https://togithub.com/tox-dev/tox/releases/tag/4.4.11)

[Compare
Source](https://togithub.com/tox-dev/tox/compare/4.4.10...4.4.11)

#### What's Changed

- Allow plugins to set `tox_root` by
[@&#8203;kdestin](https://togithub.com/kdestin) in
[tox-dev/tox#2978

#### New Contributors

- [@&#8203;kdestin](https://togithub.com/kdestin) made their first
contribution in
[tox-dev/tox#2978

**Full Changelog**:
tox-dev/tox@4.4.10...4.4.11

### [`v4.4.10`](https://togithub.com/tox-dev/tox/releases/tag/4.4.10)

[Compare
Source](https://togithub.com/tox-dev/tox/compare/4.4.9...4.4.10)

#### What's Changed

- Bump deps and tools by
[@&#8203;gaborbernat](https://togithub.com/gaborbernat) in
[tox-dev/tox#2976
- Fix `tox_root` propagation to `work_dir` by
[@&#8203;Tbruno25](https://togithub.com/Tbruno25) in
[tox-dev/tox#2962

#### New Contributors

- [@&#8203;Tbruno25](https://togithub.com/Tbruno25) made their first
contribution in
[tox-dev/tox#2962

**Full Changelog**:
tox-dev/tox@4.4.9...4.4.10

### [`v4.4.9`](https://togithub.com/tox-dev/tox/releases/tag/4.4.9)

[Compare Source](https://togithub.com/tox-dev/tox/compare/4.4.8...4.4.9)

#### What's Changed

- Added python 3.11 by
[@&#8203;ElBe-Plaq](https://togithub.com/ElBe-Plaq) in
[tox-dev/tox#2964
- Document running tox within a Docker container by
[@&#8203;31z4](https://togithub.com/31z4) in
[tox-dev/tox#2923
- Correct Docker image working dir by
[@&#8203;31z4](https://togithub.com/31z4) in
[tox-dev/tox#2965
- Avoid UnicodeDecodeError from command output by
[@&#8203;masenf](https://togithub.com/masenf) in
[tox-dev/tox#2970
- Bump pypa/gh-action-pypi-publish from 1.8.3 to 1.8.5 by
[@&#8203;dependabot](https://togithub.com/dependabot) in
[tox-dev/tox#2971

#### New Contributors

- [@&#8203;ElBe-Plaq](https://togithub.com/ElBe-Plaq) made their first
contribution in
[tox-dev/tox#2964
- [@&#8203;31z4](https://togithub.com/31z4) made their first
contribution in
[tox-dev/tox#2923

**Full Changelog**: tox-dev/tox@4.4.8...4.4.9

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Enabled.

♻ **Rebasing**: Whenever PR is behind base branch, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS4xMC4yIiwidXBkYXRlZEluVmVyIjoiMzUuMTAuMiJ9-->

Co-authored-by: descope[bot] <descope[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants