From 01330d6328807175eda9504d02824fdd209e6c64 Mon Sep 17 00:00:00 2001
From: Eleni Mathioulaki <emathioulaki@athenarc.gr>
Date: Mon, 15 Apr 2024 10:55:09 +0300
Subject: [PATCH] update DAG hash calculation to include test dependencies

Spack's spec hashing mechanism considers only build, link, and run dependencies, overlooking test dependencies. As a result, although Spack correctly concretizes environments when `--test root` is specified (including test dependencies), the resulting lockfile dict only includes the deps whose types affect the hash (build/link/run) and when the env is loaded, test dependencies are not, and tests fail. The workaround suggested in the Spack issue [here](https://github.com/spack/spack/issues/29447) is deleting the lockfile every time and allowing `spack install --test root` to recreate it. By extending Spack's default hash type to include test dependencies, the need for this workaround is eliminated and concretization and installation can be split into separate steps.
---
 lib/spack/spack/hash_types.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/spack/spack/hash_types.py b/lib/spack/spack/hash_types.py
index c1e25198cb3..737678bd6d7 100644
--- a/lib/spack/spack/hash_types.py
+++ b/lib/spack/spack/hash_types.py
@@ -39,7 +39,7 @@ def __call__(self, spec):
 
 
 #: Spack's deployment hash. Includes all inputs that can affect how a package is built.
-dag_hash = SpecHashDescriptor(depflag=dt.BUILD | dt.LINK | dt.RUN, package_hash=True, name="hash")
+dag_hash = SpecHashDescriptor(depflag=dt.BUILD | dt.LINK | dt.RUN | dt.TEST, package_hash=True, name="hash")
 
 
 #: Hash descriptor used only to transfer a DAG, as is, across processes
-- 
GitLab