diff --git a/conans/model/conf.py b/conans/model/conf.py index 52dd76d6669..087913f02b7 100644 --- a/conans/model/conf.py +++ b/conans/model/conf.py @@ -470,10 +470,12 @@ def copy_conaninfo_conf(self): # Reading the list of all the configurations selected by the user to use for the package_id package_id_confs = self.get("tools.info.package_id:confs", default=[], check_type=list) for conf_name in package_id_confs: - value = self.get(conf_name) - # Pruning any empty values, those should not affect package ID - if value: - result.define(conf_name, value) + matching_confs = [c for c in BUILT_IN_CONFS if re.match(conf_name, c)] or [conf_name] + for name in matching_confs: + value = self.get(name) + # Pruning any empty values, those should not affect package ID + if value: + result.define(name, value) return result def set_relative_base_folder(self, folder): diff --git a/conans/test/integration/configuration/conf/test_conf_copy.py b/conans/test/integration/configuration/conf/test_conf_copy.py new file mode 100644 index 00000000000..47218636e8d --- /dev/null +++ b/conans/test/integration/configuration/conf/test_conf_copy.py @@ -0,0 +1,54 @@ +import os +import platform +import textwrap + +import pytest +from mock import patch + +from conan import conan_version +from conans.errors import ConanException +from conans.util.files import save, load +from conans.test.utils.tools import TestClient + +from conans.model.conf import Conf + + +def test_copy_conaninfo_conf(): + conf = Conf() + + conf.define("core:non_interactive", True) + conf.define("tools.cmake.cmaketoolchain:generator", True) + conf.define("tools.deployer:symlinks", True) + + pattern = [".*"] + conf.define("tools.info.package_id:confs", pattern) + result = conf.copy_conaninfo_conf().dumps() + assert "tools.info.package_id:confs=%s" % pattern in result + assert "core:non_interactive" in result + assert "tools.cmake.cmaketoolchain:generator=True" in result + assert "tools.deployer:symlinks" in result + + pattern = ["tools\..*"] + conf.define("tools.info.package_id:confs", pattern) + result = conf.copy_conaninfo_conf().dumps() + assert "tools.info.package_id:confs=%s" % pattern in result + assert "core:non_interactive" not in result + assert "tools.cmake.cmaketoolchain:generator=True" in result + assert "tools.deployer:symlinks" in result + + pattern = [".*cmake"] + conf.define("tools.info.package_id:confs", pattern) + result = conf.copy_conaninfo_conf().dumps() + assert "tools.info.package_id:confs=%s" % pattern not in result + assert "core:non_interactive" not in result + assert "tools.cmake.cmaketoolchain:generator=True" in result + assert "tools.deployer:symlinks" not in result + + pattern = ["(tools.deploy|core)"] + conf.define("tools.info.package_id:confs", pattern) + result = conf.copy_conaninfo_conf().dumps() + assert "tools.info.package_id:confs=%s" % pattern not in result + assert "core:non_interactive" in result + assert "tools.cmake.cmaketoolchain:generator=True" not in result + assert "tools.deployer:symlinks" in result +