diff options
author | Todd Gamblin <tgamblin@llnl.gov> | 2022-04-23 18:09:08 -0700 |
---|---|---|
committer | Todd Gamblin <tgamblin@llnl.gov> | 2022-05-13 10:45:12 -0700 |
commit | 7ab46e26b561e40b7e1fd5bc926c5012aee3e153 (patch) | |
tree | 24554a20d55e0566d2a097f2ed6dc7799b7cbd14 /lib/spack/spack/test/util/package_hash.py | |
parent | 6db215dd890d02afb26c2a946d976a52c01209f4 (diff) | |
download | spack-7ab46e26b561e40b7e1fd5bc926c5012aee3e153.tar.gz spack-7ab46e26b561e40b7e1fd5bc926c5012aee3e153.tar.bz2 spack-7ab46e26b561e40b7e1fd5bc926c5012aee3e153.tar.xz spack-7ab46e26b561e40b7e1fd5bc926c5012aee3e153.zip |
`content_hash()`: make it work on abstract specs
Some test cases had to be modified in a kludgy way so that abstract specs made
concrete would have versions on them. We shouldn't *need* to do this, as the
only reason we care is because the content hash has to be able to get an archive
for a version.
This modifies the content hash so that it can be called on abstract specs,
including only relevant content.
This does NOT add a partial content hash to the DAG hash, as we do not really
want that -- we don't need in-memory spec hashes to need to load package files.
It just makes `Package.content_hash()` less prickly and tests easier to
understand.
Diffstat (limited to 'lib/spack/spack/test/util/package_hash.py')
-rw-r--r-- | lib/spack/spack/test/util/package_hash.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/spack/spack/test/util/package_hash.py b/lib/spack/spack/test/util/package_hash.py index dd674b01f9..3133cd08a7 100644 --- a/lib/spack/spack/test/util/package_hash.py +++ b/lib/spack/spack/test/util/package_hash.py @@ -96,6 +96,26 @@ def test_content_hash_all_same_but_patch_contents(mock_packages, config): compare_hash_sans_name(False, spec1, spec2) +def test_content_hash_not_concretized(mock_packages, config): + """Check that Package.content_hash() works on abstract specs.""" + # these are different due to the package hash + spec1 = Spec("hash-test1@1.1") + spec2 = Spec("hash-test2@1.3") + compare_hash_sans_name(False, spec1, spec2) + + # at v1.1 these are actually the same package when @when's are removed + # and the name isn't considered + spec1 = Spec("hash-test1@1.1") + spec2 = Spec("hash-test2@1.1") + compare_hash_sans_name(True, spec1, spec2) + + # these end up being different b/c we can't eliminate much of the package.py + # without a version. + spec1 = Spec("hash-test1") + spec2 = Spec("hash-test2") + compare_hash_sans_name(False, spec1, spec2) + + def test_content_hash_different_variants(mock_packages, config): spec1 = Spec("hash-test1@1.2 +variantx").concretized() spec2 = Spec("hash-test2@1.2 ~variantx").concretized() |