Skip to content

Commit

Permalink
Fixed search options locally (conan-io#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote authored and memsharded committed Oct 13, 2016
1 parent b5baaec commit 2fa6ba7
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 10 deletions.
29 changes: 19 additions & 10 deletions conans/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,32 @@ def compatible_prop(setting_value, prop_value):
return setting_value is None or prop_value == setting_value

for prop_name, prop_value in properties.items():
if prop_name == "os" and not compatible_prop(conan_vars_info.settings.os, prop_value):
if prop_name == "os":
if compatible_prop(conan_vars_info.settings.os, prop_value):
continue
return True
elif prop_name == "compiler" and not compatible_prop(conan_vars_info.settings.compiler,
prop_value):
elif prop_name == "compiler":
if compatible_prop(conan_vars_info.settings.compiler, prop_value):
continue
return True
elif prop_name.startswith("compiler."):
subsetting = prop_name[9:]
if not compatible_prop(getattr(conan_vars_info.settings.compiler, subsetting),
prop_value):
return True
elif prop_name == "arch" and not compatible_prop(conan_vars_info.settings.arch, prop_value):
prop = getattr(conan_vars_info.settings.compiler, subsetting)
if compatible_prop(prop, prop_value):
continue
return True
elif prop_name == "arch":
if compatible_prop(conan_vars_info.settings.arch, prop_value):
continue
return True
elif prop_name == "build_type" and not compatible_prop(conan_vars_info.settings.build_type,
prop_value):
elif prop_name == "build_type":
if compatible_prop(conan_vars_info.settings.build_type, prop_value):
continue
return True
else:
if getattr(conan_vars_info.options, prop_name) == prop_value:
if hasattr(conan_vars_info.options, prop_name):
if getattr(conan_vars_info.options, prop_name) == prop_value:
continue
return True
return False

Expand Down
14 changes: 14 additions & 0 deletions conans/test/command/search_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,17 @@ def package_search_properties_filter_test(self):
compiler.version: 4.3
""", self.client.user_io.out)

self.client.run('search helloTest/1.4.10@fenix/stable -q use_OpenGL=False')
self.assertIn("There are no packages for reference 'helloTest/1.4.10@fenix/stable' "
"matching the query 'use_OpenGL=False'", self.client.user_io.out)

self.client.run('search helloTest/1.4.10@fenix/stable -q use_OpenGL=True')
self.assertIn("Existing packages for recipe helloTest/1.4.10@fenix/stable", self.client.user_io.out)

self.client.run('search helloTest/1.4.10@fenix/stable -q "use_OpenGL=True AND arch=x64"')
self.assertIn("Existing packages for recipe helloTest/1.4.10@fenix/stable", self.client.user_io.out)

self.client.run('search helloTest/1.4.10@fenix/stable -q "use_OpenGL=True AND arch=x86"')
self.assertIn("There are no packages for reference 'helloTest/1.4.10@fenix/stable' "
"matching the query 'use_OpenGL=True AND arch=x86'", self.client.user_io.out)

0 comments on commit 2fa6ba7

Please sign in to comment.