set code default for config:build_stage

Signed-off-by: Gregory Becker <becker33@llnl.gov>
This commit is contained in:
Gregory Becker 2024-11-25 15:23:35 -08:00
parent ced6f984ea
commit 0df5b8616c
2 changed files with 13 additions and 1 deletions

View File

@ -176,13 +176,14 @@ def _resolve_paths(candidates):
# Cached stage path root
_stage_root = None
_default_stage_config = ["$tmpdir/$user/spack-stage", "$user_cache_path/stage"]
def get_stage_root():
global _stage_root
if _stage_root is None:
candidates = spack.config.get("config:build_stage")
candidates = spack.config.get("config:build_stage", _default_stage_config)
if isinstance(candidates, str):
candidates = [candidates]

View File

@ -754,6 +754,17 @@ def test_get_stage_root_bad_path(self, clear_stage_root):
# Make sure the cached stage path values are unchanged.
assert spack.stage._stage_root is None
def test_get_stage_root_empty(self, clear_stage_root):
# build stage set to empty by user is respected and errors
with spack.config.override("config:build_stage::", []):
with pytest.raises(spack.stage.StageError):
spack.stage.get_stage_root()
# No build stage set (config section set to empty) uses default
expected = spack.stage._resolve_paths(spack.stage._default_stage_config)[0]
with spack.config.override("config::", {}):
assert spack.stage.get_stage_root() == expected
@pytest.mark.parametrize(
"path,purged",
[