summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/solver/concretize.lp14
-rw-r--r--lib/spack/spack/test/concretize_preferences.py3
2 files changed, 17 insertions, 0 deletions
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index d6d6c835ca..baf1c5239f 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -504,6 +504,13 @@ root(Dependency, 1) :- not root(Dependency), node(Dependency).
Weight@14,Package,Variant,Value
: variant_not_default(Package, Variant, Value, Weight), root(Package)
}.
+% If the value is a multivalued variant there could be multiple
+% values set as default. Since a default value has a weight of 0 we
+% need to maximize their number below to ensure they're all set
+#maximize {
+ 1@13,Package,Variant,Value
+ : variant_not_default(Package, Variant, Value, Weight), root(Package)
+}.
#minimize{
Weight@13,Provider
: provider_weight(Provider, Weight), root(Provider)
@@ -538,6 +545,13 @@ root(Dependency, 1) :- not root(Dependency), node(Dependency).
Weight@9,Package,Variant,Value
: variant_not_default(Package, Variant, Value, Weight), not root(Package)
}.
+% If the value is a multivalued variant there could be multiple
+% values set as default. Since a default value has a weight of 0 we
+% need to maximize their number below to ensure they're all set
+#maximize {
+ 1@8,Package,Variant,Value
+ : variant_not_default(Package, Variant, Value, Weight), not root(Package)
+}.
#minimize{
Weight@8,Package : version_weight(Package, Weight)
}.
diff --git a/lib/spack/spack/test/concretize_preferences.py b/lib/spack/spack/test/concretize_preferences.py
index c138632ffa..d13748ad8b 100644
--- a/lib/spack/spack/test/concretize_preferences.py
+++ b/lib/spack/spack/test/concretize_preferences.py
@@ -80,6 +80,9 @@ class TestConcretizePreferences(object):
# Use different values for the variants and check them again
('mpileaks', ['+debug', '+opt', '~shared', '-static'],
{'debug': True, 'opt': True, 'shared': False, 'static': False}),
+ # Check a multivalued variant with multiple values set
+ ('multivalue-variant', ['foo=bar,baz', 'fee=bar'],
+ {'foo': ('bar', 'baz'), 'fee': 'bar'})
])
def test_preferred_variants(
self, package_name, variant_value, expected_results