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

test to validate runenv_info is propagated #12948

Merged
merged 2 commits into from
Jan 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions conans/test/integration/environment/test_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,3 +720,48 @@ def build(self):
client.run("create dep -s arch=armv8.3")
client.run("create consumer -s arch=armv8.3")
assert "DUMMY=123456" in client.out


def test_runenv_info_propagated():
"""
A runenv_info in a recipe, which is required by an executable that is used
in another place as a tool_require (also its own test_package), should be
propagated
test_package --(tool_requires)->tools-(requires)->lib(defines runenv_info)
https://github.com/conan-io/conan/issues/12939
"""
c = TestClient()
lib = textwrap.dedent("""
from conan import ConanFile
class Lib(ConanFile):
name = "lib"
version = "0.1"
settings = "build_type"
def package_info(self):
self.runenv_info.define("MYLIBVAR", f"MYLIBVALUE:{self.settings.build_type}")
""")
tool_test_package = textwrap.dedent("""
import platform
from conan import ConanFile
class TestTool(ConanFile):
settings = "build_type"
test_type = "explicit"
generators = "VirtualBuildEnv"
def build_requirements(self):
self.tool_requires(self.tested_reference_str)
def build(self):
self.output.info(f"Building TEST_PACKAGE IN {self.settings.build_type}!!")
if platform.system()!= "Windows":
self.run("echo MYLIBVAR=$MYLIBVAR")
else:
self.run("set MYLIBVAR")
def test(self):
pass
""")
c.save({"lib/conanfile.py": lib,
"tool/conanfile.py": GenConanfile("tool", "0.1").with_requires("lib/0.1"),
"tool/test_package/conanfile.py": tool_test_package})
c.run("create lib -s build_type=Release")
c.run("create tool --build-require -s:b build_type=Release -s:h build_type=Debug")
assert "tool/0.1 (test package): Building TEST_PACKAGE IN Debug!!" in c.out
assert "MYLIBVAR=MYLIBVALUE:Release" in c.out