Skip to content

Commit 71077ee

Browse files
committed
experiment with visible=False trait equivalence
1 parent 1eda2e4 commit 71077ee

File tree

3 files changed

+66
-4
lines changed

3 files changed

+66
-4
lines changed

conan/internal/model/requires.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ def __eq__(self, other):
229229
(self.headers and other.headers) or
230230
(self.libs and other.libs) or
231231
(self.run and other.run) or
232-
((self.visible or self.test) and (other.visible or other.test)) or
232+
(self.test and other.test) or
233+
(self.visible or other.visible) or # THIS IS AN OR!!
233234
(self.ref == other.ref and self.options == other.options)))
234235

235236
def aggregate(self, other):

test/integration/graph/conflict_diamond_test.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,64 @@ def test_transitive_orphans(self, order, test):
385385
assert dep_pkg2["visible"] is True
386386
assert dep_pkg3["ref"] == "pkg3/1.1"
387387
assert dep_pkg2["visible"] is True
388+
389+
390+
def test_visible_order_issue():
391+
# libc -> libb/1.0 (static) -> lib_a/1.1 (header)
392+
# \-------------------------------/
393+
# Order mattered here
394+
# libc2 ---------------------> lib_a/1.1 (header)
395+
# \----> libb/1.0 (static) -> lib_a/1.2 (header)
396+
c = TestClient(light=True)
397+
c.save({"liba/conanfile.py": GenConanfile("lib_a").with_package_type("header-library"),
398+
"libb/conanfile.py": GenConanfile("lib_b", "1.0").with_package_type("static-library")
399+
.with_requires("lib_a/[>=1]"),
400+
"libc/conanfile.py": GenConanfile("lib_c", "1.0").with_package_type("shared-library")
401+
.with_requirement("lib_b/1.0",
402+
visible=False)
403+
.with_requirement("lib_a/1.1"),
404+
"libc2/conanfile.py": GenConanfile("lib_c", "1.0").with_package_type("shared-library")
405+
.with_requirement("lib_a/1.1")
406+
.with_requirement("lib_b/1.0",
407+
visible=False),
408+
})
409+
c.run("export liba --version=1.0")
410+
c.run("export liba --version=1.1")
411+
c.run("export liba --version=1.2")
412+
c.run("export libb")
413+
c.run("graph info libc --format=json")
414+
graph = json.loads(c.stdout)
415+
assert len(graph["graph"]["nodes"]) == 3
416+
417+
c.run("graph info libc2 --format=json")
418+
graph = json.loads(c.stdout)
419+
assert len(graph["graph"]["nodes"]) == 3
420+
421+
422+
def test_visible_order_full_diamond_issue():
423+
c = TestClient(light=True)
424+
c.save({"liba/conanfile.py": GenConanfile("lib_a").with_package_type("header-library"),
425+
"libb/conanfile.py": GenConanfile("lib_b", "1.0").with_package_type("static-library")
426+
.with_requires("lib_a/[>=1]"),
427+
"libd/conanfile.py": GenConanfile("lib_d", "1.0").with_package_type("static-library")
428+
.with_requires("lib_a/1.1"),
429+
"libc/conanfile.py": GenConanfile("lib_c", "1.0").with_package_type("shared-library")
430+
.with_requirement("lib_b/1.0",
431+
visible=False)
432+
.with_requirement("lib_d/1.0"),
433+
"libc2/conanfile.py": GenConanfile("lib_c", "1.0").with_package_type("shared-library")
434+
.with_requirement("lib_d/1.0")
435+
.with_requirement("lib_b/1.0",
436+
visible=False),
437+
})
438+
c.run("export liba --version=1.0")
439+
c.run("export liba --version=1.1")
440+
c.run("export liba --version=1.2")
441+
c.run("export libb")
442+
c.run("export libd")
443+
c.run("graph info libc", assert_error=True)
444+
assert "ERROR: Version conflict: Conflict between lib_a/1.1 and lib_a/1.2 in the graph" in c.out
445+
446+
c.run("graph info libc2 --format=json")
447+
graph = json.loads(c.stdout)
448+
assert len(graph["graph"]["nodes"]) == 4

test/integration/graph/ux/loop_detection_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,6 @@ def generate(self):
8181
"app/conanfile.py": conanfile})
8282

8383
c.run("create cmake")
84-
c.run("install app")
85-
# It doesn't hang, and it sees correctly just 1 dependency
86-
assert "conanfile.py (test/1.0): NUM DEPS: 1" in c.out
84+
c.run("install app", assert_error=True)
85+
# It doesn't hang, and it sees correctly the duplicated dependency
86+
assert "Duplicated requirement: cmake/3.31.6" in c.out

0 commit comments

Comments
 (0)