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

fix for test_requires required components #17174

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions conans/model/requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ def aggregate(self, other):
self.transitive_libs = self.transitive_libs or other.transitive_libs
if not other.test:
self.test = False # it it was previously a test, but also required by non-test
self.is_test = self.is_test or other.is_test
# package_id_mode is not being propagated downstream. So it is enough to check if the
# current require already defined it or not
if self.package_id_mode is None:
Expand Down Expand Up @@ -344,6 +345,7 @@ def transform_downstream(self, pkg_type, require, dep_pkg_type):

if self.test:
downstream_require.test = True
downstream_require.is_test = require.is_test

# If the current one is resolving conflicts, the downstream one will be too
downstream_require.force = require.force
Expand Down
32 changes: 32 additions & 0 deletions test/integration/graph/test_test_requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,38 @@ def package_info(self):
assert "libc/0.1: Created package" in c.out


def test_requires_transitive_diamond_components_order():
"""
like the above, but in different order
libc --(test-requires)---> liba
|-----> libb -----------/
https://github.com/conan-io/conan/issues/17164
"""
c = TestClient(light=True)
libc = textwrap.dedent("""
from conan import ConanFile
class LibC(ConanFile):
name = "libc"
version = "0.1"

def requirements(self):
self.test_requires("liba/1.0")
self.requires("libb/1.0")

def package_info(self):
self.cpp_info.components["comp"].libs = ["libc"]
self.cpp_info.components["comp"].requires.append("libb::libb")
""")
c.save({"liba/conanfile.py": GenConanfile("liba", "1.0"),
"libb/conanfile.py": GenConanfile("libb", "1.0").with_requires("liba/1.0"),
"libc/conanfile.py": libc})
c.run("create liba")
c.run("create libb")
c.run("create libc")
# This used to crash due to component not defined to liba
assert "libc/0.1: Created package" in c.out


def test_test_requires_options():
""" the default_options = {} values also propagate to ``test_requires()`` """
c = TestClient(light=True)
Expand Down