From c105a8d42a0c052ad5fb7bdd9a25ee9b25008ff7 Mon Sep 17 00:00:00 2001 From: Todd Gamblin Date: Tue, 24 Mar 2015 08:41:42 -0700 Subject: Small updates to directives. --- lib/spack/spack/directives.py | 6 ++---- lib/spack/spack/test/spec_semantics.py | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/spack/spack/directives.py b/lib/spack/spack/directives.py index a45edecad1..2ae56fce33 100644 --- a/lib/spack/spack/directives.py +++ b/lib/spack/spack/directives.py @@ -240,14 +240,12 @@ def patch(pkg, url_or_filename, **kwargs): @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 +variant/-variant in a spec. You can optionally supply an 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'" % (pkg.name, name)) diff --git a/lib/spack/spack/test/spec_semantics.py b/lib/spack/spack/test/spec_semantics.py index 5fb09e68af..1db7956f04 100644 --- a/lib/spack/spack/test/spec_semantics.py +++ b/lib/spack/spack/test/spec_semantics.py @@ -71,7 +71,7 @@ class SpecSematicsTest(MockPackagesTest): # ================================================================================ - # Satisfiability and constraints + # Satisfiability # ================================================================================ def test_satisfies(self): self.check_satisfies('libelf@0.8.13', '@0:1') @@ -96,6 +96,9 @@ class SpecSematicsTest(MockPackagesTest): 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_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): self.check_satisfies('foo=chaos_5_x86_64_ib', '=chaos_5_x86_64_ib') @@ -147,7 +150,16 @@ class SpecSematicsTest(MockPackagesTest): 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%gcc@4.5:4.6', 'libelf@0:2.5%gcc@2:4.6', 'libelf@2.1:3%gcc@4.5:4.7') @@ -158,6 +170,8 @@ class SpecSematicsTest(MockPackagesTest): self.check_constrain('libelf+debug~foo', 'libelf+debug', 'libelf~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', 'libelf=bgqos_0') @@ -170,8 +184,3 @@ class SpecSematicsTest(MockPackagesTest): self.check_invalid_constraint('libelf+debug~foo', 'libelf+debug+foo') 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') -- cgit v1.2.3-70-g09d2