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

Environment variables required across unrelated environments #515

Closed
AndreLouisCaron opened this issue May 18, 2017 · 0 comments · Fixed by #521
Closed

Environment variables required across unrelated environments #515

AndreLouisCaron opened this issue May 18, 2017 · 0 comments · Fixed by #521

Comments

@AndreLouisCaron
Copy link
Contributor

@AndreLouisCaron AndreLouisCaron commented May 18, 2017

Hi there,

I have an issue where if one environment uses an {env:X} subsitution (without default), then that environment variable is required in all environments regardless of whether they are necessary or not.

Given this example tox.ini file:

[tox]
skipsdist = true

[testenv:standard-greeting]
commands =
  python -c 'print("Hello, world!")'

[testenv:custom-greeting]
passenv =
  NAME
commands =
  python -c 'print("Hello, {env:NAME}!"'

Then custom-greeting environment cannot be used unless NAME is present in the calling environment, even if that environment doesn't use the {env:NAME}.

$ tox -e standard-greeting
tox.ConfigError: ConfigError: substitution env:'NAME': unknown environment variable 'NAME'  or recursive definition.

I got this with tox 2.7.0 with both Python 3.5 and 2.7 on Windows.

obestwalter added a commit that referenced this issue Sep 4, 2017
* #595 fix by updating implementation of #515

The way #515 was implemented did not play nicely with env var substitution. This might render the former additions completely or partially obsolete but I did not check this yet. First let's fix that bug.

* fix flakes

(cherry picked from commit e902f04)

* #595 fix by updating implementation of #515

The way #515 was implemented did not play nicely with env var substitution. This might render the former additions completely or partially obsolete but I did not check this yet. First let's fix that bug.

Instead of crashing early on testenv creation if the substitution the missing substitution keys are added to a list attached to TestenvConfig. This way it is not necessary anymore to provide everything needed to resolve all testenvs but instead only what is needed to resolve all testenvs that are part of this restrun.

Implementation notes:

The first implementation used a module level mapping from envname to missing substitutions, which was ugly. Instead the information is bubbled up as an exception where it can be handled the way it is needed in the contexts where the information can be either translated into a crashing error or attached to the object which should carry the information (in this case TestenvConfig).

Atm a missing substitution in a testenv is not being left empty but filled with a special value 'TOX_MISSING_SUBSTITUTION', this is not exactly necessary, but I don't feel comfortable enough yet to leave it empty, this can help with debugging potential problems that might arise from this change.

* #595 missed a bit

Crash only if actually trying to run a testenv with missing substitutions

* fix error on execution

Instead of crashing the whole thing again - only later, do it the right way by setting venv.status with the error to be reported later.

* #595 tests and last touches

* catch MissingSubstition from all method calls for consistency
* set status and stop execution in setupvenv if substutions are missing to prevent errors occuring there with missing substitutions
tchaikov added a commit to tchaikov/ceph that referenced this issue Apr 18, 2018
rhel/centos 7.3 comes with tox 1.4.2, which has a bunch of issues related
to environment variable substitution. for instance, see
- tox-dev/tox#515
so, instead of having different coverage files for py3 and py2.7, it
would be simpler to just use the same path for coverage. this approach
works because pytest-cov plugin erases the coverage data file at the
beginning of test[1].

---
[1] https://pypi.org/project/pytest-cov/#coverage-data-file .

Signed-off-by: Kefu Chai <kchai@redhat.com>
tchaikov added a commit to tchaikov/ceph that referenced this issue Apr 18, 2018
rhel/centos 7.3 comes with tox 1.4.2, which has a bunch of issues related
to environment variable substitution. for instance, see
- tox-dev/tox#515
so, instead of having different coverage files for py3 and py2.7, it
would be simpler to just use the same path for coverage. this approach
works because pytest-cov plugin erases the coverage data file at the
beginning of test[1].

---
[1] https://pypi.org/project/pytest-cov/#coverage-data-file .

Signed-off-by: Kefu Chai <kchai@redhat.com>
tchaikov added a commit to tchaikov/ceph that referenced this issue Apr 18, 2018
2.8.1 brings an important fix, see
tox-dev/tox#515.

Signed-off-by: Kefu Chai <kchai@redhat.com>
tchaikov added a commit to tchaikov/ceph that referenced this issue Apr 19, 2018
2.8.1 brings an important fix, see
tox-dev/tox#515.

Signed-off-by: Kefu Chai <kchai@redhat.com>
tchaikov added a commit to tchaikov/ceph that referenced this issue Apr 19, 2018
2.8.1 brings an important fix, see
tox-dev/tox#515.

Signed-off-by: Kefu Chai <kchai@redhat.com>
epuertat added a commit to rhcs-dashboard/ceph that referenced this issue Sep 10, 2018
rhel/centos 7.3 comes with tox 1.4.2, which has a bunch of issues related
to environment variable substitution. for instance, see
- tox-dev/tox#515
so, instead of having different coverage files for py3 and py2.7, it
would be simpler to just use the same path for coverage. this approach
works because pytest-cov plugin erases the coverage data file at the
beginning of test[1].

---
[1] https://pypi.org/project/pytest-cov/#coverage-data-file .

Signed-off-by: Kefu Chai <kchai@redhat.com>

(cherry picked from commit 32b07dd)

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
epuertat added a commit to rhcs-dashboard/ceph that referenced this issue Sep 18, 2018
rhel/centos 7.3 comes with tox 1.4.2, which has a bunch of issues related
to environment variable substitution. for instance, see
- tox-dev/tox#515
so, instead of having different coverage files for py3 and py2.7, it
would be simpler to just use the same path for coverage. this approach
works because pytest-cov plugin erases the coverage data file at the
beginning of test[1].

---
[1] https://pypi.org/project/pytest-cov/#coverage-data-file .

Signed-off-by: Kefu Chai <kchai@redhat.com>

(cherry picked from commit 32b07dd)

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
epuertat added a commit to rhcs-dashboard/ceph that referenced this issue Sep 26, 2018
rhel/centos 7.3 comes with tox 1.4.2, which has a bunch of issues related
to environment variable substitution. for instance, see
- tox-dev/tox#515
so, instead of having different coverage files for py3 and py2.7, it
would be simpler to just use the same path for coverage. this approach
works because pytest-cov plugin erases the coverage data file at the
beginning of test[1].

---
[1] https://pypi.org/project/pytest-cov/#coverage-data-file .

Signed-off-by: Kefu Chai <kchai@redhat.com>

(cherry picked from commit 32b07dd)

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
epuertat added a commit to rhcs-dashboard/ceph that referenced this issue Sep 26, 2018
rhel/centos 7.3 comes with tox 1.4.2, which has a bunch of issues related
to environment variable substitution. for instance, see
- tox-dev/tox#515
so, instead of having different coverage files for py3 and py2.7, it
would be simpler to just use the same path for coverage. this approach
works because pytest-cov plugin erases the coverage data file at the
beginning of test[1].

---
[1] https://pypi.org/project/pytest-cov/#coverage-data-file .

Signed-off-by: Kefu Chai <kchai@redhat.com>

(cherry picked from commit 32b07dd)

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
epuertat added a commit to rhcs-dashboard/ceph that referenced this issue Oct 1, 2018
rhel/centos 7.3 comes with tox 1.4.2, which has a bunch of issues related
to environment variable substitution. for instance, see
- tox-dev/tox#515
so, instead of having different coverage files for py3 and py2.7, it
would be simpler to just use the same path for coverage. this approach
works because pytest-cov plugin erases the coverage data file at the
beginning of test[1].

---
[1] https://pypi.org/project/pytest-cov/#coverage-data-file .

Signed-off-by: Kefu Chai <kchai@redhat.com>

(cherry picked from commit 32b07dd)

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
epuertat added a commit to rhcs-dashboard/ceph that referenced this issue Oct 17, 2018
rhel/centos 7.3 comes with tox 1.4.2, which has a bunch of issues related
to environment variable substitution. for instance, see
- tox-dev/tox#515
so, instead of having different coverage files for py3 and py2.7, it
would be simpler to just use the same path for coverage. this approach
works because pytest-cov plugin erases the coverage data file at the
beginning of test[1].

---
[1] https://pypi.org/project/pytest-cov/#coverage-data-file .

Signed-off-by: Kefu Chai <kchai@redhat.com>

(cherry picked from commit 32b07dd)

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
epuertat added a commit to rhcs-dashboard/ceph that referenced this issue Oct 26, 2018
rhel/centos 7.3 comes with tox 1.4.2, which has a bunch of issues related
to environment variable substitution. for instance, see
- tox-dev/tox#515
so, instead of having different coverage files for py3 and py2.7, it
would be simpler to just use the same path for coverage. this approach
works because pytest-cov plugin erases the coverage data file at the
beginning of test[1].

---
[1] https://pypi.org/project/pytest-cov/#coverage-data-file .

Signed-off-by: Kefu Chai <kchai@redhat.com>

(cherry picked from commit 32b07dd)

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>

Signed-off-by: Ernesto Puerta <epuertat@redhat.com>
@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.

2 participants