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

commands substitution does not work if commands uses '{posargs}' #279

Closed
pytoxbot opened this issue Sep 17, 2016 · 13 comments
Closed

commands substitution does not work if commands uses '{posargs}' #279

pytoxbot opened this issue Sep 17, 2016 · 13 comments

Comments

@pytoxbot
Copy link

@pytoxbot pytoxbot commented Sep 17, 2016

[testenv:sect1]
commands = something {posargs}

[testenv:sect2]
commands = {[testenv:sect1]commands}

$  tox -e sect2

  File "/usr/bin/tox", line 9, in <module>
    load_entry_point('tox==2.1.1', 'console_scripts', 'tox')()
  File "/usr/lib/python3.5/site-packages/tox/session.py", line 38, in main
    config = prepare(args)
  File "/usr/lib/python3.5/site-packages/tox/session.py", line 26, in prepare
    config = parseconfig(args)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 219, in parseconfig
    parseini(config, inipath)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 669, in __init__
    self.make_envconfig(name, section, reader._subs, config)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 697, in make_envconfig
    res = meth(env_attr.name, env_attr.default)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 864, in getargvlist
    return _ArgvlistReader.getargvlist(self, s)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 1013, in getargvlist
    replaced = reader._replace(current_command)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 982, in _replace
    return RE_ITEM_REF.sub(self._replace_match, x)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 978, in _replace_match
    return handler(match)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 948, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 937, in _substitute_from_other_section
    return self._replace(x)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 982, in _replace
    return RE_ITEM_REF.sub(self._replace_match, x)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 978, in _replace_match
    return handler(match)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 948, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/usr/lib/python3.5/site-packages/tox/config.py", line 942, in _substitute_from_other_section
    "substitution key %r not found" % key)
tox.ConfigError: ConfigError: substitution key 'posargs' not found
@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

Original comment by burkov-bostongene

Sorry, I 've a bug in this config: commands = ./runtests.py --nolint {posargs} is underindented. I fixed indentation and it works now.

@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

Original comment by @nakato

2.3.0 was released before this patch.

There is currently not a release with this patch in it.

@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

Original comment by burkov-bostongene

I've tried the following tox.ini with both tox 1.7.0 and tox 2.3.0 and both result in

Traceback (most recent call last):
  File "/usr/local/bin/tox", line 11, in <module>
    sys.exit(cmdline())
  File "/usr/local/lib/python2.7/dist-packages/tox/session.py", line 38, in main
    config = prepare(args)
  File "/usr/local/lib/python2.7/dist-packages/tox/session.py", line 26, in prepare
    config = parseconfig(args)
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 229, in parseconfig
    parseini(config, inipath)
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 729, in __init__
    self.make_envconfig(name, section, reader._subs, config)
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 764, in make_envconfig
    res = reader.getlist(env_attr.name, sep="\n")
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 882, in getlist
    s = self.getstring(name, None)
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 949, in getstring
    x = self._replace(x, name=name, crossonly=crossonly)
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 973, in _replace
    return Replacer(self, crossonly=crossonly).do_replace(value)
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 992, in do_replace
    return self.RE_ITEM_REF.sub(self._replace_match, x)
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 1021, in _replace_match
    return self._replace_substitution(match)
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 1067, in _replace_substitution
    val = self._substitute_from_other_section(sub_key)
  File "/usr/local/lib/python2.7/dist-packages/tox/config.py", line 1061, in _substitute_from_other_section
    "substitution key %r not found" % key)
tox.ConfigError: ConfigError: substitution key 'posargs' not found

tox.ini:

[tox]
envlist=dj{18,19,110}-py{27,35}-me{09,010}

[testenv]
deps =
    -rrequirements_dev.txt
    dj18: Django==1.8.*
    dj19: Django==1.9.*
    dj110: Django==1.10.*
    djangorestframework==3.*
    blinker==1.*
    me09: mongoengine==0.9.*
    me09: pymongo==2.*
    me010: mongoengine==0.10.*
    me010: pymongo==3.*
    commands = ./runtests.py --nolint {posargs}

@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

Original comment by @hpk42

fix issue279: allow cross-section substitution when the value contains
posargs. Thanks Sachi King for the PR.

→ <<cset 20f9fb8d1172>>

@pytoxbot pytoxbot closed this Sep 17, 2016
@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

@pytoxbot
Copy link
Author

@pytoxbot pytoxbot commented Sep 17, 2016

Original comment by @mgedmin

Bug still present in tox 2.3.0.

@r1chardj0n3s
Copy link

@r1chardj0n3s r1chardj0n3s commented Nov 28, 2016

Is there any chance of a 2.3.2 release to get this bug fix out so downstream packagers can update (xenial and yakkety both have 2.3.1) please?

@hpk42
Copy link
Contributor

@hpk42 hpk42 commented Nov 29, 2016

we are already at 2.5 -- i am not bound myself to go for a 2.3.2, sorry. But if it's not too difficult to review i'll consider merging a PR which does a 2.3.2 into a separate branch on the repo.

@r1chardj0n3s
Copy link

@r1chardj0n3s r1chardj0n3s commented Nov 29, 2016

As far as I can tell there's nothing to change from commit 9262476 to make a 2.3.2 release, and as such I can't propose a PR for that because there's no changes to propose :-)

@hpk42
Copy link
Contributor

@hpk42 hpk42 commented Nov 30, 2016

are you saying that making a 2.3.2 release from that commit is all you need?
I uploaded a tox-2.3.2 to https://devpi.net/hpk/dev/ and am testing it ... let me know if releasing this to pypi would help you.

@r1chardj0n3s
Copy link

@r1chardj0n3s r1chardj0n3s commented Nov 30, 2016

Yes, that is perfect, thanks Holger! Please do upload to pypi so downstream can be encouraged to package it.

@robcresswell
Copy link

@robcresswell robcresswell commented Nov 30, 2016

To give a little more background on this:

  • We changed tox.ini in OpenStack Horizon to use features that are broken in 2.3.1
  • As far as I can tell, Ubuntu Xenial and Yakkety both have 2.3.1 as a system package.
  • Its usually fairly easy to get a bugfix release pushed to the system packages, so ideally we'd like to get 2.3.2 tagged. It has a release note in https://tox.readthedocs.io/en/latest/changelog.html#id4 but for some reason it was never actually tagged and released. The fix we specifically rely on is fix "issue279: allow cross-section substitution when the value contains posargs". If we could get a tagged 2.3.2 build at the point that the release notes already specify, that would be fantastic.

@hpk42
Copy link
Contributor

@hpk42 hpk42 commented Nov 30, 2016

ok, done and pushed to pypi, hope it helps. Btw, merlinux offers and is currently executing open source support contracts for devpi, tox, and pytest -- mail me for more info.

@tox-dev tox-dev locked and limited conversation to collaborators Jan 14, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants