From dc1b0662d9d6d0a242bec0534c9135b0c6158f23 Mon Sep 17 00:00:00 2001 From: psakiev Date: Sat, 29 Mar 2025 22:51:23 -0600 Subject: [PATCH] Add package tests --- lib/spack/spack/test/packages.py | 14 ++++++++++++++ .../packages/git-ref-package/package.py | 1 + 2 files changed, 15 insertions(+) diff --git a/lib/spack/spack/test/packages.py b/lib/spack/spack/test/packages.py index 9c4b1142a78..336b281f30d 100644 --- a/lib/spack/spack/test/packages.py +++ b/lib/spack/spack/test/packages.py @@ -333,3 +333,17 @@ def test_package_can_have_sparse_checkout_properties(mock_packages, mock_fetch, assert isinstance(fetcher, spack.fetch_strategy.GitFetchStrategy) assert hasattr(fetcher, "git_sparse_paths") assert fetcher.git_sparse_paths == pkg_cls.git_sparse_paths + + +def test_phil_package_can_depend_on_commit_of_dependency(mock_packages, config): + spec = spack.concretize.concretize_one(Spec("git-ref-commit-dep@1.0.0")) + assert spec.satisfies(f"^git-ref-package commit={'a' * 40}") + assert "surgical" not in spec["git-ref-package"].variants + + +def test_phil_package_condtional_variants_may_depend_on_commit(mock_packages, config): + spec = spack.concretize.concretize_one(Spec("git-ref-commit-dep@develop")) + assert spec.satisfies(f"^git-ref-package commit={'b' * 40}") + conditional_variant = spec["git-ref-package"].variants.get("surgical", None) + assert conditional_variant + assert conditional_variant.value diff --git a/var/spack/repos/builtin.mock/packages/git-ref-package/package.py b/var/spack/repos/builtin.mock/packages/git-ref-package/package.py index f6beebd69b2..c922f917c22 100644 --- a/var/spack/repos/builtin.mock/packages/git-ref-package/package.py +++ b/var/spack/repos/builtin.mock/packages/git-ref-package/package.py @@ -37,6 +37,7 @@ class GitRefPackage(AutotoolsPackage): variant("opt", default=True, description="Enable optimizations") variant("shared", default=True, description="Build shared library") variant("pic", default=True, description="Enable position-independent code (PIC)") + variant("surgical", default=True, when=f"commit={'b' * 40}", description="Testing conditional on commit") conflicts("+shared~pic")