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

always generate files VirtualBuildEnv VirtualRunEnv #11536

Merged
merged 3 commits into from Jun 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)))