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

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

Merged
Merged
Show file tree
Hide file tree
Changes from 2 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 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
36 changes: 36 additions & 0 deletions test/integration/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,3 +149,39 @@ 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)
tc.save({"dep/conanfile.py": textwrap.dedent("""
AbrilRBS marked this conversation as resolved.
Show resolved Hide resolved
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.py": 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.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
Loading