Skip to content

Section references in the same testenv are collapsed when {envname} is used #1822

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

Closed
tucked opened this issue Jan 14, 2021 · 2 comments
Closed
Labels
bug:normal affects many people or has quite an impact tox4
Milestone

Comments

@tucked
Copy link

tucked commented Jan 14, 2021

When submitting a bug make sure you can reproduce it via tox -rvv and attach the output of that to the bug. Ideally, you should also submit a project that allows easily reproducing the bug. Thanks!

[testenv]
skip_install = true

[testenv:custom]
commands_pre =
    -{envpython} -c 'import os; os.remove("foo")'
    -{envpython} -c 'import os; os.remove("bar")'
commands =
    {envpython} -c 'open("foo", "x"); open("bar", "x")'
    {[testenv:{envname}]commands_pre}
  • This is desirable to never reuse foo/bar, but to keep them around if the early commands fail. This is an SSCCE, but an equivalent real-world example can be made with pipenv/Pipfile/Pipfile.lock (to test that locking the current project always succeeds in multiple python versions).
$ tox
custom run-test-pre: PYTHONHASHSEED='345878128'
custom run-test-pre: commands[0] | -/tmp/tmp.d6HWGl8K3o/.tox/custom/bin/python -c 'import os; os.remove("foo")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'foo'
custom run-test-pre: commands[1] | -/tmp/tmp.d6HWGl8K3o/.tox/custom/bin/python -c 'import os; os.remove("bar")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: 'bar'
custom run-test: commands[0] | /tmp/tmp.d6HWGl8K3o/.tox/custom/bin/python -c 'open("foo", "x"); open("bar", "x")'
custom run-test: commands[1] | -/tmp/tmp.d6HWGl8K3o/.tox/custom/bin/python -c 'import os; os.remove("foo")' -/tmp/tmp.d6HWGl8K3o/.tox/custom/bin/python -c 'import os; os.remove("bar")'
______________________________________________________________ summary ______________________________________________________________  custom: commands succeeded
  congratulations :)
$ ll
total 4.0K
-rw-r--r-- 1 dtucker user   0 Jan 13 17:08 bar
-rw-r--r-- 1 dtucker user 268 Jan 13 17:08 tox.ini

This does not reproduce with {[testenv:custom]commands_pre} (however, that isn't usable with generative section names e.g. py{27,36}-custom instead of just custom).

@tucked tucked added the bug:normal affects many people or has quite an impact label Jan 14, 2021
@gaborbernat
Copy link
Member

This seems to work with tox4 (see rewrite branch).

tox4 config -e custom -k commands commands_pre
[testenv:custom]
commands =
  /private/tmp/.tox4/custom/bin/python -c 'open("foo", "x"); open("bar", "x")'
  -/private/tmp/.tox4/custom/bin/python -c 'import os; os.remove("foo")'
  -/private/tmp/.tox4/custom/bin/python -c 'import os; os.remove("bar")'
commands_pre =
  -/private/tmp/.tox4/custom/bin/python -c 'import os; os.remove("foo")'
  -/private/tmp/.tox4/custom/bin/python -c 'import os; os.remove("bar")'

I personally have no plans to make it work on tox 3, but if you put in a PR we can review it.

@gaborbernat
Copy link
Member

I'm closing this as is fixed in tox 4 (will be out in a few months).

@gaborbernat gaborbernat added this to the 4.0 milestone Jan 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug:normal affects many people or has quite an impact tox4
Projects
None yet
Development

No branches or pull requests

2 participants