From 5aaa16cc0a587d4f18e40bc6a7be2ad15977cd2e Mon Sep 17 00:00:00 2001 From: memsharded Date: Wed, 5 Apr 2023 01:34:30 +0200 Subject: [PATCH] fix package-query patterns for options --- conans/search/search.py | 1 + .../test/integration/command_v2/list_test.py | 31 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/conans/search/search.py b/conans/search/search.py index 6af6217dc8d..01e09bbe1ff 100644 --- a/conans/search/search.py +++ b/conans/search/search.py @@ -61,6 +61,7 @@ def compatible_prop(setting_value, _prop_value): if not prop_name.startswith("options."): return compatible_prop(info_settings.get(prop_name, None), prop_value) else: + prop_name = prop_name[len("options."):] return compatible_prop(info_options.get(prop_name, None), prop_value) diff --git a/conans/test/integration/command_v2/list_test.py b/conans/test/integration/command_v2/list_test.py index a9367e62ba8..87f5581a63c 100644 --- a/conans/test/integration/command_v2/list_test.py +++ b/conans/test/integration/command_v2/list_test.py @@ -584,6 +584,37 @@ def test_list_prefs_query_custom_settings(): assert "newsetting.subsetting: 2" not in c.out +def test_list_query_options(): + """ + Make sure query works for custom settings + https://github.com/conan-io/conan/issues/13617 + """ + c = TestClient(default_server_user=True) + c.save({"conanfile.py": GenConanfile("pkg", "1.0").with_option("myoption", [1, 2, 3])}) + c.run("create . -o myoption=1") + c.run("create . -o myoption=2") + c.run("create . -o myoption=3") + + c.run("list pkg/1.0:* -p options.myoption=1") + assert "myoption: 1" in c.out + assert "myoption: 2" not in c.out + assert "myoption: 3" not in c.out + c.run("list pkg/1.0:* -p options.myoption=2") + assert "myoption: 1" not in c.out + assert "myoption: 2" in c.out + assert "myoption: 3" not in c.out + + c.run("upload * -r=default -c") + c.run("list pkg/1.0:* -p options.myoption=1 -r=default") + assert "myoption: 1" in c.out + assert "myoption: 2" not in c.out + assert "myoption: 3" not in c.out + c.run("list pkg/1.0:* -p options.myoption=2 -r=default") + assert "myoption: 1" not in c.out + assert "myoption: 2" in c.out + assert "myoption: 3" not in c.out + + class TestListNoUserChannel: def test_no_user_channel(self): c = TestClient(default_server_user=True)