Skip to content

Commit

Permalink
always generate files VirtualBuildEnv VirtualRunEnv (#11536)
Browse files Browse the repository at this point in the history
* always generate files VirtualBuildEnv VirtualRunEnv

* add test
  • Loading branch information
memsharded committed Jun 28, 2022
1 parent a498cf2 commit ae33d68
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
3 changes: 1 addition & 2 deletions conan/tools/env/virtualbuildenv.py
Expand Up @@ -69,5 +69,4 @@ def vars(self, scope="build"):

def generate(self, scope="build"):
build_env = self.environment()
if build_env: # Only if there is something defined
build_env.vars(self._conanfile, scope=scope).save_script(self._filename)
build_env.vars(self._conanfile, scope=scope).save_script(self._filename)
3 changes: 1 addition & 2 deletions conan/tools/env/virtualrunenv.py
Expand Up @@ -73,5 +73,4 @@ def vars(self, scope="run"):

def generate(self, scope="run"):
run_env = self.environment()
if run_env:
run_env.vars(self._conanfile, scope=scope).save_script(self._filename)
run_env.vars(self._conanfile, scope=scope).save_script(self._filename)
20 changes: 20 additions & 0 deletions conans/test/integration/environment/test_env.py
Expand Up @@ -663,3 +663,23 @@ def build(self):
# client.run("create . --name consumer --version 1.0")
client.run("create . consumer/1.0@ -pr:h=default -pr:b=default")
assert "FOO is BAR" not in client.out


def test_files_always_created():
""" test that even if there are no env-variables, the generators always create files,
they will be mostly empty, but exist
"""
c = TestClient()
c.save({"dep/conanfile.py": GenConanfile("dep", "0.1"),
"consumer/conanfile.txt": "[requires]\ndep/0.1"})
c.run("create dep")
c.run("install consumer -g VirtualBuildEnv -g VirtualRunEnv")
ext = "bat" if platform.system() == "Windows" else "sh"

assert os.path.isfile(os.path.join(c.current_folder, "conanbuild.{}".format(ext)))
assert os.path.isfile(os.path.join(c.current_folder, "conanrun.{}".format(ext)))
assert os.path.isfile(os.path.join(c.current_folder,
"conanbuildenv-release-x86_64.{}".format(ext)))
assert os.path.isfile(os.path.join(c.current_folder,
"conanbuildenv-release-x86_64.{}".format(ext)))

0 comments on commit ae33d68

Please sign in to comment.