diff --git a/lib/spack/spack/test/install.py b/lib/spack/spack/test/install.py index 02b0c31e0bd..516e9511496 100644 --- a/lib/spack/spack/test/install.py +++ b/lib/spack/spack/test/install.py @@ -7,6 +7,7 @@ import shutil import sys +import pathlib import pytest import llnl.util.filesystem as fs @@ -630,3 +631,15 @@ def test_install_from_binary_with_missing_patch_succeeds( s.package.do_install(package_cache_only=True, dependencies_cache_only=True, unsigned=True) assert temporary_store.db.query_local_by_spec_hash(s.dag_hash()) + + +@pytest.mark.regression("38484") +def test_git_ref_version_can_be_reused(monkeypatch, mock_git_version_info, install_mockery): + repo_path, filename, commits = mock_git_version_info + monkeypatch.setattr( + spack.package_base.PackageBase, "git", pathlib.Path(repo_path).as_uri(), raising=False + ) + spec = spack.spec.Spec("git-test-commit@git.v1.0=1.0+generic_install+feature").concretized() + spec.package.do_install() + new_spec = spack.spec.Spec("git-test-commit@git.v1.0=1.0+generic_install~feature") + new_spec.concretize() diff --git a/var/spack/repos/builtin.mock/packages/git-test-commit/package.py b/var/spack/repos/builtin.mock/packages/git-test-commit/package.py index 66eb64e5436..c445fdbf49b 100644 --- a/var/spack/repos/builtin.mock/packages/git-test-commit/package.py +++ b/var/spack/repos/builtin.mock/packages/git-test-commit/package.py @@ -17,10 +17,14 @@ class GitTestCommit(Package): version("1.2", tag="1.2") # not a typo version("2.0", tag="v2.0") + variant("generic_install", default=False, description="Override install feature for original implementations tests") + variant("feature", default=False, description="A very cool feature") + def install(self, spec, prefix): # It is assumed for the test which installs this package, that it will # be using the earliest commit, which is contained in the range @:0 - assert spec.satisfies("@:0") + if not spec.variants["generic_install"].value: + assert spec.satisfies("@:0") mkdir(prefix.bin) # This will only exist for some second commit