summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorMassimiliano Culpo <massimiliano.culpo@gmail.com>2021-04-11 09:01:09 +0200
committerGitHub <noreply@github.com>2021-04-11 01:01:09 -0600
commit215d194482772ee3ba15c9e2700d8562c25ab6bd (patch)
treee8803e7d00dfb2c8c340800c1a00ec09373a6064 /lib
parent291a2b541b8d82945fcf7edf5083ecc88d1f322d (diff)
downloadspack-215d194482772ee3ba15c9e2700d8562c25ab6bd.tar.gz
spack-215d194482772ee3ba15c9e2700d8562c25ab6bd.tar.bz2
spack-215d194482772ee3ba15c9e2700d8562c25ab6bd.tar.xz
spack-215d194482772ee3ba15c9e2700d8562c25ab6bd.zip
ASP-based solver: assign OS correctly with inheritance from parent (#22896)
fixes #22871 When in presence of multiple choices for the operating system we were lacking a rule to derive the node OS if it was inherited.
Diffstat (limited to 'lib')
-rw-r--r--lib/spack/spack/solver/concretize.lp2
-rw-r--r--lib/spack/spack/test/concretize.py16
-rw-r--r--lib/spack/spack/test/data/config/compilers.yaml10
3 files changed, 28 insertions, 0 deletions
diff --git a/lib/spack/spack/solver/concretize.lp b/lib/spack/spack/solver/concretize.lp
index 898927a8a8..51ab721744 100644
--- a/lib/spack/spack/solver/concretize.lp
+++ b/lib/spack/spack/solver/concretize.lp
@@ -478,6 +478,8 @@ node_os_inherit(Dependency, OS)
not node_os_set(Dependency).
node_os_inherit(Package) :- node_os_inherit(Package, _).
+node_os(Package, OS) :- node_os_inherit(Package, OS).
+
% fall back to default if not set or inherited
node_os(Package, OS)
:- node(Package),
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index 78b7ca9491..fda09cebb1 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -1183,3 +1183,19 @@ class TestConcretize(object):
assert '~foo' in s['external-non-default-variant']
assert '~bar' in s['external-non-default-variant']
assert s['external-non-default-variant'].external
+
+ @pytest.mark.regression('22871')
+ @pytest.mark.parametrize('spec_str,expected_os', [
+ ('mpileaks', 'os=debian6'),
+ # To trigger the bug in 22871 we need to have the same compiler
+ # spec available on both operating systems
+ ('mpileaks%gcc@4.5.0 platform=test os=debian6', 'os=debian6'),
+ ('mpileaks%gcc@4.5.0 platform=test os=redhat6', 'os=redhat6')
+ ])
+ def test_os_selection_when_multiple_choices_are_possible(
+ self, spec_str, expected_os
+ ):
+ s = Spec(spec_str).concretized()
+
+ for node in s.traverse():
+ assert node.satisfies(expected_os)
diff --git a/lib/spack/spack/test/data/config/compilers.yaml b/lib/spack/spack/test/data/config/compilers.yaml
index 641331dc9f..e0b0464976 100644
--- a/lib/spack/spack/test/data/config/compilers.yaml
+++ b/lib/spack/spack/test/data/config/compilers.yaml
@@ -20,6 +20,16 @@ compilers:
modules: 'None'
target: x86_64
- compiler:
+ spec: gcc@4.5.0
+ operating_system: redhat6
+ paths:
+ cc: /path/to/gcc
+ cxx: /path/to/g++
+ f77: None
+ fc: None
+ modules: 'None'
+ target: x86_64
+- compiler:
spec: clang@3.3
operating_system: CNL
paths: