Small updates to directives.

This commit is contained in:
Todd Gamblin 2015-03-24 08:41:42 -07:00
parent 1f8ce403dc
commit c105a8d42a
2 changed files with 18 additions and 11 deletions

View File

@ -240,14 +240,12 @@ def patch(pkg, url_or_filename, **kwargs):
@directive(dicts='variants') @directive(dicts='variants')
def variant(pkg, name, description="", **kwargs): def variant(pkg, name, description=""):
"""Define a variant for the package. Allows the user to supply """Define a variant for the package. Allows the user to supply
+variant/-variant in a spec. You can optionally supply an +variant/-variant in a spec. You can optionally supply an
initial + or - to make the variant enabled or disabled by defaut. initial + or - to make the variant enabled or disabled by defaut.
""" """
return if not re.match(r'^[-~+]?[A-Za-z0-9_][A-Za-z0-9_.-]*$', name):
if not re.match(r'[-~+]?[A-Za-z0-9_][A-Za-z0-9_.-]*', name):
raise DirectiveError("Invalid variant name in %s: '%s'" raise DirectiveError("Invalid variant name in %s: '%s'"
% (pkg.name, name)) % (pkg.name, name))

View File

@ -71,7 +71,7 @@ def check_invalid_constraint(self, spec, constraint):
# ================================================================================ # ================================================================================
# Satisfiability and constraints # Satisfiability
# ================================================================================ # ================================================================================
def test_satisfies(self): def test_satisfies(self):
self.check_satisfies('libelf@0.8.13', '@0:1') self.check_satisfies('libelf@0.8.13', '@0:1')
@ -96,6 +96,9 @@ def test_satisfies_compiler_version(self):
self.check_unsatisfiable('foo@4.0%pgi', '@1:3%pgi') self.check_unsatisfiable('foo@4.0%pgi', '@1:3%pgi')
self.check_unsatisfiable('foo@4.0%pgi@4.5', '@1:3%pgi@4.4:4.6') self.check_unsatisfiable('foo@4.0%pgi@4.5', '@1:3%pgi@4.4:4.6')
self.check_satisfies('foo %gcc@4.7.3', '%gcc@4.7')
self.check_unsatisfiable('foo %gcc@4.7', '%gcc@4.7.3')
def test_satisfies_architecture(self): def test_satisfies_architecture(self):
self.check_satisfies('foo=chaos_5_x86_64_ib', '=chaos_5_x86_64_ib') self.check_satisfies('foo=chaos_5_x86_64_ib', '=chaos_5_x86_64_ib')
@ -147,7 +150,16 @@ def test_satisfies_virtual_dependency_versions(self):
self.check_unsatisfiable('mpileaks^mpi@3:', '^mpich@1.0') self.check_unsatisfiable('mpileaks^mpi@3:', '^mpich@1.0')
def test_constrain(self): def test_satisfies_variant(self):
self.check_satisfies('foo %gcc@4.7.3', '%gcc@4.7')
self.check_unsatisfiable('foo %gcc@4.7', '%gcc@4.7.3')
# ================================================================================
# Constraints
# ================================================================================
def test_constrain_variants(self):
self.check_constrain('libelf@2.1:2.5', 'libelf@0:2.5', 'libelf@2.1:3') self.check_constrain('libelf@2.1:2.5', 'libelf@0:2.5', 'libelf@2.1:3')
self.check_constrain('libelf@2.1:2.5%gcc@4.5:4.6', self.check_constrain('libelf@2.1:2.5%gcc@4.5:4.6',
'libelf@0:2.5%gcc@2:4.6', 'libelf@2.1:3%gcc@4.5:4.7') 'libelf@0:2.5%gcc@2:4.6', 'libelf@2.1:3%gcc@4.5:4.7')
@ -158,6 +170,8 @@ def test_constrain(self):
self.check_constrain('libelf+debug~foo', 'libelf+debug', 'libelf~foo') self.check_constrain('libelf+debug~foo', 'libelf+debug', 'libelf~foo')
self.check_constrain('libelf+debug~foo', 'libelf+debug', 'libelf+debug~foo') self.check_constrain('libelf+debug~foo', 'libelf+debug', 'libelf+debug~foo')
def test_constrain_arch(self):
self.check_constrain('libelf=bgqos_0', 'libelf=bgqos_0', 'libelf=bgqos_0') self.check_constrain('libelf=bgqos_0', 'libelf=bgqos_0', 'libelf=bgqos_0')
self.check_constrain('libelf=bgqos_0', 'libelf', 'libelf=bgqos_0') self.check_constrain('libelf=bgqos_0', 'libelf', 'libelf=bgqos_0')
@ -170,8 +184,3 @@ def test_invalid_constraint(self):
self.check_invalid_constraint('libelf+debug~foo', 'libelf+debug+foo') self.check_invalid_constraint('libelf+debug~foo', 'libelf+debug+foo')
self.check_invalid_constraint('libelf=bgqos_0', 'libelf=x86_54') self.check_invalid_constraint('libelf=bgqos_0', 'libelf=x86_54')
def test_compiler_satisfies(self):
self.check_satisfies('foo %gcc@4.7.3', '%gcc@4.7')
self.check_unsatisfiable('foo %gcc@4.7', '%gcc@4.7.3')