From 92789b1437fad559ac3e72f510eae521f01d4552 Mon Sep 17 00:00:00 2001 From: James Date: Tue, 30 Apr 2019 14:35:53 +0200 Subject: [PATCH] fixed problem with transitive build_requires (#5056) * fixed problem with transitive build_requires * comment fix --- conans/client/graph/graph_builder.py | 3 +++ .../build_requires/build_requires_test.py | 15 +++++++++++++++ .../test/functional/graph/graph_manager_test.py | 2 +- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/conans/client/graph/graph_builder.py b/conans/client/graph/graph_builder.py index 9067ab65ea2..14f8fb39f1d 100644 --- a/conans/client/graph/graph_builder.py +++ b/conans/client/graph/graph_builder.py @@ -148,6 +148,9 @@ def _handle_require(self, name, node, require, dep_graph, check_updates, update, new_node.inverse_closure.add(node) node.public_deps[new_node.name] = new_node + # If the parent node is a build-require, this new node will be a build-require + # If the requirement is a build-require, this node will also be a build-require + new_node.build_require = node.build_require or require.build_require # New nodes will inherit the private property of its ancestor new_node.private = node.private or require.private if require.private or require.build_require: diff --git a/conans/test/functional/build_requires/build_requires_test.py b/conans/test/functional/build_requires/build_requires_test.py index 763873309d2..a2e3e8b02bd 100644 --- a/conans/test/functional/build_requires/build_requires_test.py +++ b/conans/test/functional/build_requires/build_requires_test.py @@ -6,6 +6,7 @@ from conans.paths import CONANFILE from conans.test.utils.tools import TestClient from conans.util.files import load +from conans.test.utils.conanfile import TestConanFile tool_conanfile = """from conans import ConanFile @@ -50,6 +51,20 @@ def build_requirements(self): class BuildRequiresTest(unittest.TestCase): + def test_build_requires_diamond(self): + t = TestClient() + t.save({"conanfile.py": str(TestConanFile("libA", "0.1"))}) + t.run("create . libA/0.1@user/testing") + + t.save({"conanfile.py": str(TestConanFile("libB", "0.1", + requires=["libA/0.1@user/testing"]))}) + t.run("create . libB/0.1@user/testing") + + t.save({"conanfile.py": str(TestConanFile("libC", "0.1", + build_requires=["libB/0.1@user/testing", + "libA/0.1@user/testing"]))}) + t.run("create . libC/0.1@user/testing") + self.assertIn("libC/0.1@user/testing: Created package", t.out) def create_with_tests_and_build_requires_test(self): client = TestClient() diff --git a/conans/test/functional/graph/graph_manager_test.py b/conans/test/functional/graph/graph_manager_test.py index ccf9f1c810c..fa8d793d520 100644 --- a/conans/test/functional/graph/graph_manager_test.py +++ b/conans/test/functional/graph/graph_manager_test.py @@ -768,7 +768,7 @@ def test_dont_conflict_private(self, private_first): self._check_node(liba2, "liba/0.2@user/testing#123", deps=[], build_deps=[], dependents=[libc], closure=[]) - def consecutive_private(self): + def test_consecutive_private(self): liba_ref = "liba/0.1@user/testing" libb_ref = "libb/0.1@user/testing" libc_ref = "libc/0.1@user/testing"