summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/spack/spack/hash_types.py4
-rw-r--r--lib/spack/spack/spec.py8
-rw-r--r--lib/spack/spack/test/concretize.py8
3 files changed, 15 insertions, 5 deletions
diff --git a/lib/spack/spack/hash_types.py b/lib/spack/spack/hash_types.py
index 0f8d20fb5b..abe8a0b282 100644
--- a/lib/spack/spack/hash_types.py
+++ b/lib/spack/spack/hash_types.py
@@ -33,6 +33,10 @@ class SpecHashDescriptor(object):
"""Private attribute stored on spec"""
return '_' + self.name
+ def __call__(self, spec):
+ """Run this hash on the provided spec."""
+ return spec.spec_hash(self)
+
#: Spack's deployment hash. Includes all inputs that can affect how a package is built.
dag_hash = SpecHashDescriptor(
diff --git a/lib/spack/spack/spec.py b/lib/spack/spack/spec.py
index c49878cd37..cf27a8db68 100644
--- a/lib/spack/spack/spec.py
+++ b/lib/spack/spack/spec.py
@@ -1754,7 +1754,7 @@ class Spec(object):
def prefix(self, value):
self._prefix = spack.util.prefix.Prefix(pth.convert_to_platform_path(value))
- def _spec_hash(self, hash):
+ def spec_hash(self, hash):
"""Utility method for computing different types of Spec hashes.
Arguments:
@@ -1771,7 +1771,7 @@ class Spec(object):
def _cached_hash(self, hash, length=None):
"""Helper function for storing a cached hash on the spec.
- This will run _spec_hash() with the deptype and package_hash
+ This will run spec_hash() with the deptype and package_hash
parameters, and if this spec is concrete, it will store the value
in the supplied attribute on this spec.
@@ -1779,13 +1779,13 @@ class Spec(object):
hash (spack.hash_types.SpecHashDescriptor): type of hash to generate.
"""
if not hash.attr:
- return self._spec_hash(hash)[:length]
+ return self.spec_hash(hash)[:length]
hash_string = getattr(self, hash.attr, None)
if hash_string:
return hash_string[:length]
else:
- hash_string = self._spec_hash(hash)
+ hash_string = self.spec_hash(hash)
if self.concrete:
setattr(self, hash.attr, hash_string)
diff --git a/lib/spack/spack/test/concretize.py b/lib/spack/spack/test/concretize.py
index 698041de98..4c2c8f5bb2 100644
--- a/lib/spack/spack/test/concretize.py
+++ b/lib/spack/spack/test/concretize.py
@@ -16,6 +16,7 @@ import llnl.util.lang
import spack.compilers
import spack.concretize
import spack.error
+import spack.hash_types as ht
import spack.platforms
import spack.repo
import spack.variant as vt
@@ -1287,7 +1288,12 @@ class TestConcretize(object):
new_root_without_reuse = Spec('root').concretized()
- assert root.dag_hash() == new_root_with_reuse.dag_hash()
+ # validate that the graphs are the same with reuse, but not without
+ assert ht.build_hash(root) == ht.build_hash(new_root_with_reuse)
+ assert ht.build_hash(root) != ht.build_hash(new_root_without_reuse)
+
+ # package hashes are different, so dag hashes will be different
+ assert root.dag_hash() != new_root_with_reuse.dag_hash()
assert root.dag_hash() != new_root_without_reuse.dag_hash()
@pytest.mark.regression('20784')