summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTodd Gamblin <tgamblin@llnl.gov>2015-03-24 08:41:42 -0700
committerTodd Gamblin <tgamblin@llnl.gov>2015-05-10 12:24:03 -0700
commitc105a8d42a0c052ad5fb7bdd9a25ee9b25008ff7 (patch)
treeaf341dd7b06e10118ecfc651b5657e9559d4c218 /lib
parent1f8ce403dcc84a741bdef8dc08db1b8182690386 (diff)
downloadspack-c105a8d42a0c052ad5fb7bdd9a25ee9b25008ff7.tar.gz
spack-c105a8d42a0c052ad5fb7bdd9a25ee9b25008ff7.tar.bz2
spack-c105a8d42a0c052ad5fb7bdd9a25ee9b25008ff7.tar.xz
spack-c105a8d42a0c052ad5fb7bdd9a25ee9b25008ff7.zip
Small updates to directives.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/directives.py6
-rw-r--r--lib/spack/spack/test/spec_semantics.py23
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')