portage.dep._use_dep: better validation, enable all tests
authorSebastian Luther <SebastianLuther@gmx.de>
Fri, 23 Jul 2010 19:12:07 +0000 (21:12 +0200)
committerZac Medico <zmedico@gentoo.org>
Fri, 23 Jul 2010 19:18:03 +0000 (12:18 -0700)
pym/portage/dep/__init__.py
pym/portage/tests/dep/testAtom.py

index c58a83e4489b3fa5b91bb672053cb9a3b2af8d8f..e6f2362b11f676f5c5d210ee4a9f91c566923ecc 100644 (file)
@@ -399,6 +399,8 @@ class _use_dep(object):
                                if "!" == first_char:
                                        conditional.disabled.append(
                                                self._validate_flag(x, x[1:-1]))
+                               elif first_char in ("-", "=", "?"):
+                                       raise InvalidAtom(_("Invalid use dep: '%s'") % (x,))
                                else:
                                        conditional.enabled.append(
                                                self._validate_flag(x, x[:-1]))
@@ -407,13 +409,20 @@ class _use_dep(object):
                                if "!" == first_char:
                                        conditional.not_equal.append(
                                                self._validate_flag(x, x[1:-1]))
+                               elif first_char in ("-", "=", "?"):
+                                       raise InvalidAtom(_("Invalid use dep: '%s'") % (x,))
                                else:
                                        conditional.equal.append(
                                                self._validate_flag(x, x[:-1]))
 
+                       elif last_char in ("!", "-"):
+                               raise InvalidAtom(_("Invalid use dep: '%s'") % (x,))
+
                        else:
                                if "-" == first_char:
                                        disabled_flags.append(self._validate_flag(x, x[1:]))
+                               elif first_char in ("!", "=", "?"):
+                                       raise InvalidAtom(_("Invalid use dep: '%s'") % (x,))
                                else:
                                        enabled_flags.append(self._validate_flag(x, x))
 
index 7457babb7753db837b0bf93e02a6c1c0903296ff..091cef3a21319f07d25efe8e0921855c83ca35db 100644 (file)
@@ -32,14 +32,14 @@ class TestAtom(TestCase):
                
                tests_xfail = [
                        ( "cat/pkg[a!]", False ),
-                       #( "cat/pkg[a-]", False ),
+                       ( "cat/pkg[a-]", False ),
                        ( "cat/pkg[!a]", False ),
                        ( "cat/pkg[!a!]", False ),
                        ( "cat/pkg[!a-]", False ),
                        ( "cat/pkg[-a=]", False ),
                        ( "cat/pkg[-a?]", False ),
                        ( "cat/pkg[-a!]", False ),
-                       #( "cat/pkg[-a-]", False ),
+                       ( "cat/pkg[-a-]", False ),
                        ( "cat/pkg[=a]", False ),
                        ( "cat/pkg[=a=]", False ),
                        ( "cat/pkg[=a?]", False ),