Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:conan-io/conan into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
lasote committed Oct 13, 2016
2 parents 2711baa + 2fa6ba7 commit b7bccf8
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 21 deletions.
24 changes: 13 additions & 11 deletions conans/model/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,17 +54,8 @@ def package_scope(self, name=None):
def from_list(items):
result = Scopes()
for item in items:
chunks = item.split(":")
if len(chunks) == 2:
root = chunks[0]
scope = chunks[1]
elif len(chunks) == 1:
root = _root
scope = chunks[0]
else:
raise ConanException("Bad scope %s" % item)
try:
key, value = scope.split("=")
key, value = item.split("=")
except:
raise ConanException("Bad scope %s" % item)
v = value.upper()
Expand All @@ -74,7 +65,18 @@ def from_list(items):
value = False
elif v == "NONE":
value = None
result[root][key] = value

chunks = key.split(":")
if len(chunks) == 2:
root = chunks[0]
scope = chunks[1]
elif len(chunks) == 1:
root = _root
scope = chunks[0]
else:
raise ConanException("Bad scope %s" % item)

result[root][scope] = value
return result

def update_scope(self, other):
Expand Down
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)
25 changes: 25 additions & 0 deletions conans/test/model/scope_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import unittest
from conans.model.scope import Scopes


class ScopeTest(unittest.TestCase):

def from_list_test(self):
scope = Scopes.from_list(["theroot:thescope=http://conan.io"])
self.assertEquals(scope["theroot"]["thescope"], "http://conan.io")
self.assertEquals(scope.package_scope("theroot")["thescope"], "http://conan.io")

scope = Scopes.from_list(["thescope=http://conan.io"])
self.assertEquals(scope["0CONAN_ROOT*"]["thescope"], "http://conan.io")

scope = Scopes.from_list(["theroot:thescope=TRUE"])
self.assertTrue(scope["theroot"]["thescope"])

scope = Scopes.from_list(["theroot:thescope=true"])
self.assertTrue(scope["theroot"]["thescope"])

scope = Scopes.from_list(["theroot:thescope=FALSE"])
self.assertFalse(scope["theroot"]["thescope"])

scope = Scopes.from_list(["theroot:thescope=false"])
self.assertFalse(scope["theroot"]["thescope"])

0 comments on commit b7bccf8

Please sign in to comment.