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

Unexpected setenv behavior #137

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

Unexpected setenv behavior #137

pytoxbot opened this issue Sep 17, 2016 · 5 comments

Comments

@pytoxbot
Copy link

The following behavior was unexpected to me. With an ini section like the following:

[testenv]
setenv = FOO = bar
commands = echo {env:FOO}

The environment variable FOO set via setenv is not reflected in the {env:FOO} substitution. I think the documentation should clarify this because it may be surprising to some. Also, there is a typo here (unkown -> unknown).

@pytoxbot
Copy link
Author

Original comment by @cjerdonek

I think the trickiest thing will be deciding the rules for what behavior you want. For example, should it be procedurally evaluated (i.e. dependent on the order in which directives are processed), or declarative (i.e. order independent). An example of this is whether it matters if the setenv directives come before or after the substitutions they might affect.

@pytoxbot
Copy link
Author

Original comment by @hpk42

You are right. The implementation might not be a few lines of change.

FYI I am actually unhappy about the "up front" expansion on all configs. It should be more lazy. For example, i once had a specific test environment that depended on an environment variable. The environment was not part of envlist, though. I only wanted to execute it sometimes and would be fine if tox gets back to me saying it needs that env variable. As it stands, however, this doesn't work because all environments need to properly expand up-front even if some of them are not actually needed. I haven't really looked into what is needed to make things more lazy. Hopefully it is a change that can be confined to config.py mostly.

@pytoxbot
Copy link
Author

Original comment by @cjerdonek

Hmm, this might become subtle then, or not so simple to document. If {env:*} needs to respect setenv, then the behavior could get complicated with things like the following (here is a simple case):

setenv =
  FOO = 1000
  BAR = {env:FOO}

Currently, because {env:*} expands to the values at start-up, there is never any ambiguity.

@pytoxbot
Copy link
Author

Original comment by @hpk42

Agreed, this should be fixed, actually. setenv should work for substitutions in commands.

@ghost ghost mentioned this issue Jul 11, 2017
obestwalter added a commit that referenced this issue Jul 11, 2017
Verify that Issue #137 is fixed.
@obestwalter
Copy link
Member

As the merged test from @sifuraz shows, this bug has been fixed already.

@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
Development

No branches or pull requests

2 participants