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 missing is_test fix of 2.9.3 #17495

Closed
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: 1 addition & 1 deletion conan/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from conans.model.conan_file import ConanFile
from conan.tools.scm import Version as _Version

__version__ = '2.10.2'
__version__ = '2.10.3'
conan_version = _Version(__version__)
2 changes: 1 addition & 1 deletion conans/model/requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,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
# necessary even if no propagation, order of requires matter
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
Expand Down Expand Up @@ -347,7 +348,6 @@ 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
44 changes: 44 additions & 0 deletions test/integration/graph/test_test_requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,8 @@ def test_requires_transitive_diamond_components_order():
like the above, but in different order
libc --(test-requires)---> liba
|-----> libb -----------/
libc->liba => test=False, direct=True, is_test=True
direct_dependencies (components check) => False
https://github.com/conan-io/conan/issues/17164
"""
c = TestClient(light=True)
Expand Down Expand Up @@ -230,6 +232,48 @@ def package_info(self):
assert "libc/0.1: Created package" in c.out


def test_wrong_requirement_test_requires():
""" https://github.com/conan-io/conan/issues/17312

app --------> etas --------------> enum
\\-->hwinfo-/---(test_requires)---/
\\-----------------------------/

app->enum => test=False, direct=True, is_test=True
direct_dependencies (components check) => True
"""
c = TestClient(light=True)
app = textwrap.dedent("""
from conan import ConanFile
class Pkg(ConanFile):
name = "app"
version = "0.1"
requires = "etas/0.1", "enum/0.1", "hwinfo/0.1"

def generate(self):
for r, d in self.dependencies.items():
assert not (r.direct and r.is_test)

def package_info(self):
self.cpp_info.requires = ["etas::etas", "enum::enum", "hwinfo::hwinfo"]
""")
files = {
"enum/conanfile.py": GenConanfile("enum", "0.1"),
"etas/conanfile.py": GenConanfile("etas", "0.1").with_requirement("enum/0.1"),
"hwinfo/conanfile.py": GenConanfile("hwinfo", "0.1").with_requirement("etas/0.1")
.with_test_requires("enum/0.1"),
"app/conanfile.py": app,
}
c.save(files)
c.run("create enum")
c.run("create etas")
c.run("create hwinfo")
# The assert in generate() doesnt fail
c.run("install app")
# the package_info() doesn't fail
c.run("create app")


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