Skip to content

Commit

Permalink
Don't use a reference for new component properties lists when merging (
Browse files Browse the repository at this point in the history
…#17503)

* Don't use a reference for new component properties lists when merging

* Add test

* Cleanup tests
  • Loading branch information
AbrilRBS authored Dec 18, 2024
1 parent 5fbf896 commit cd7f0be
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
2 changes: 1 addition & 1 deletion conans/model/build_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ def merge_list(o, d):
if existing is not None and isinstance(existing, list) and not overwrite:
existing.extend(v)
else:
current_values[k] = v
current_values[k] = copy.copy(v)

def set_relative_base_folder(self, folder):
for varname in _DIRS_VAR_NAMES:
Expand Down
40 changes: 40 additions & 0 deletions test/integration/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,43 @@ def package_info(self):
# This used to crash, because override was not correctly excluded
c.run("create app")
assert "app/0.1: Created package" in c.out

def test_duplication_component_properties():
""" Regression for PR 17503 - component lists would be incorrectly aggregated """
tc = TestClient(light=True)

dep = textwrap.dedent("""
from conan import ConanFile
class Dep(ConanFile):
name = "dep"
version = "0.1"
def package_info(self):
self.cpp_info.components["acomp"].set_property("prop_list", ["value1"])
self.cpp_info.components["bcomp"].set_property("prop_list", ["value2"])
self.cpp_info.components["ccomp"].set_property("prop_list", ["value3"])
""")

conanfile = textwrap.dedent("""
from conan import ConanFile
class Pkg(ConanFile):
name = "pkg"
version = "0.1"
requires = "dep/0.1"
def generate(self):
# Calling this would break property lists of the last lex sorted component
aggregated_components = self.dependencies["dep"].cpp_info.aggregated_components()
ccomp = self.dependencies["dep"].cpp_info.components["ccomp"]
self.output.info("ccomp list: " + str(ccomp.get_property("prop_list")))
""")

tc.save({"dep/conanfile.py": dep,
"conanfile.py": conanfile})
tc.run("create dep")
tc.run("create .")
# The bug would give ccomp the prop_list values of the other two components
assert "pkg/0.1: ccomp list: ['value3', 'value2', 'value1']" not in tc.out
assert "pkg/0.1: ccomp list: ['value3']" in tc.out

0 comments on commit cd7f0be

Please sign in to comment.