[Pytest-commit] Issue #352: TOX DELETED ALL OF MY CODE (hpk42/tox)
Andrew Tipton
issues-reply at bitbucket.org
Tue Jul 26 22:50:59 EDT 2016
New issue 352: TOX DELETED ALL OF MY CODE
https://bitbucket.org/hpk42/tox/issues/352/tox-deleted-all-of-my-code
Andrew Tipton:
TL;DR: due to a (slightly) wrong `tox` invocation... tox punished me by deleting all of the files in my project.
Transcript of my shell session:
```
$ pwd
/home/andrew/tmp/dataplanet
$ ls -l
total 44
4 -rw-r--r-- 1 andrew andrew 311 Jul 27 10:47 bitbucket-pipelines.yml
4 drwxr-xr-x 2 andrew andrew 4096 Jul 27 10:47 docs
4 -rw-r--r-- 1 andrew andrew 167 Jul 27 10:47 MANIFEST.in
8 -rw-r--r-- 1 andrew andrew 4308 Jul 27 10:47 README
4 -rw-r--r-- 1 andrew andrew 1021 Jul 27 10:47 setup.cfg
4 -rw-r--r-- 1 andrew andrew 1564 Jul 27 10:47 setup.py
4 drwxr-xr-x 4 andrew andrew 4096 Jul 27 10:47 src
4 drwxr-xr-x 2 andrew andrew 4096 Jul 27 10:47 tests
4 -rw-r--r-- 1 andrew andrew 998 Jul 27 10:47 TODO
4 -rw-r--r-- 1 andrew andrew 1147 Jul 27 10:47 tox.ini
$ tox -e tests
GLOB sdist-make: /home/andrew/tmp/dataplanet/setup.py
tests create: /home/andrew/tmp/dataplanet
ERROR: invocation failed (exit code 1), logfile: /home/andrew/tmp/dataplanet/log/tests-0.log
ERROR: actionid: tests
msg: getenv
cmdargs: ['/usr/bin/python3', '-m', 'virtualenv', '--python', '/usr/bin/python3', 'dataplanet']
ERROR: InvocationError: /usr/bin/python3 -m virtualenv --python /usr/bin/python3 dataplanet (see /home/andrew/tmp/dataplanet/log/tests-0.log)
env: {... environment variables omitted ...}
Traceback (most recent call last):
File "/home/andrew/.local/lib/python3.4/site-packages/virtualenv.py", line 840, in install_wheel
from urlparse import urljoin
ImportError: No module named 'urlparse'
_________________________________________________________________ summary __________________________________________________________________
ERROR: tests: InvocationError: /usr/bin/python3 -m virtualenv --python /usr/bin/python3 dataplanet (see /home/andrew/tmp/dataplanet/log/tests-0.log)
andrew at ip-10-0-20-167:~/tmp/dataplanet>
total 0
$ pwd
/home/andrew/tmp/dataplanet
$ cd ../dataplanet
$ ls -l
total 16
4 drwxr-xr-x 2 andrew andrew 4096 Jul 27 10:39 bin
4 drwxr-xr-x 2 andrew andrew 4096 Jul 27 10:39 include
4 drwxr-xr-x 3 andrew andrew 4096 Jul 27 10:39 lib
4 drwxr-xr-x 2 andrew andrew 4096 Jul 27 10:39 log
$ pwd
/home/andrew/tmp/dataplanet
```
Here's a minimal `tox.ini` that will reproduce the problem:
```
[tox]
envlist = check, py34-tests
[testenv]
envdir=
check: {toxworkdir}/py
py34: {toxworkdir}/py34
skip_install=
check: true
tests: false
deps=
check: flake8
tests: pytest
commands=
check: flake8 --show-source {toxinidir}/src
tests: py.test --strict --doctest-modules {toxinidir}/tests
```
Did you see what happened there? I *meant* to run `tox -e py34-tests`, but instead ran `tox -e tests`. This somehow resulted in `{toxworkdir}` getting set to `{toxinidir}` (!!!) and as a result tox helpfully deleted my project's code and replaced it with a tox working directory....
*THIS IS NOT ACCEPTABLE BEHAVIOUR.*
In case you're wondering "why configure things in this particular manner?", my full configuration has additional environments e.g. `py27-tests`, `py34-docs`, `py34-build`, etc. and I want to speed things up by sharing the working directory between these different targets. (That is, I want exactly one `toxworkdir` per Python version.)
More information about the pytest-commit
mailing list