'commands' variable cannot be substituted

Issue #145 on hold
Ben Darnell created an issue

Using substitution on the 'commands' variable does not appear to work - the substituted string is passed as a single token to the subprocess module. I would expect the splitting to be done after performing the substitution.

Stripped down example:

[tox]
envlist=py26, py27, py32, py33

[testenv]
commands = python -c 'print "py2"'

[testenv:py32]
commands = python -c 'print("py3")'

[testenv:py33]
commands = {[testenv:py32]commands}

Output:

GLOB sdist-make: /private/tmp/toxtest/setup.py
py26 inst-nodeps: /private/tmp/toxtest/.tox/dist/UNKNOWN-0.0.0.zip
py26 runtests: commands[0] | python -c print "py2"
py2
py27 recreate: /private/tmp/toxtest/.tox/py27
py27 inst: /private/tmp/toxtest/.tox/dist/UNKNOWN-0.0.0.zip
py27 runtests: commands[0] | python -c print "py2"
py2
py32 inst-nodeps: /private/tmp/toxtest/.tox/dist/UNKNOWN-0.0.0.zip
py32 runtests: commands[0] | python -c print("py3")
py3
py33 inst-nodeps: /private/tmp/toxtest/.tox/dist/UNKNOWN-0.0.0.zip
py33 runtests: commands[0] | python -c 'print("py3")'
ERROR: InvocationError: could not find executable 'python -c \'print("py3")\''
___________________________________ summary ____________________________________
  py26: commands succeeded
  py27: commands succeeded
  py32: commands succeeded
ERROR:   py33: commands failed

Comments (4)

  1. Holger Krekel repo owner

    i am a bit surprised that your example output seems to work for <py33. In any case, it's kind of a known issue that substitution does not work with commands, only with deps for which it was introduced. I am not immediately sure what needs to be done to support it.

  2. Ben Darnell reporter

    The different python versions don't mean anything; it fails on py33 because that's the one where I attempted to substitute the commands variable. (I wanted to illustrate that I can share one command line globally with the [testenv] section, but can't share different command lines across different subsets of the tests)

    My real-world use case is https://github.com/facebook/tornado/blob/5a9194f7f31d7a290b887c02a949c0d9ea5dbd7c/tox.ini#L114-125

    I'm trying to run various combinations of python versions, dependencies, and command lines with as little repetition in the tox.ini as possible. Substituting the command line is just one way to do this of course; other options include some sort of configuration matrix (as seen in travis-ci), pattern matching (a section named [testenv:*-curl] would be applied to all matching environments) or some sort of decoupling of virtualenvs and commands (I don't really want to create a new virtualenv for each of my test configurations here, but I still want them to be addressable with 'tox -e' and reported individually)

  3. Log in to comment