From 0df5b8616c2555343530212344e1c14f193e7fba Mon Sep 17 00:00:00 2001 From: Gregory Becker Date: Mon, 25 Nov 2024 15:23:35 -0800 Subject: [PATCH] set code default for config:build_stage Signed-off-by: Gregory Becker --- lib/spack/spack/stage.py | 3 ++- lib/spack/spack/test/stage.py | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/spack/spack/stage.py b/lib/spack/spack/stage.py index 84949c2e287..01ed0ebedcd 100644 --- a/lib/spack/spack/stage.py +++ b/lib/spack/spack/stage.py @@ -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] diff --git a/lib/spack/spack/test/stage.py b/lib/spack/spack/test/stage.py index 36a9e2eef25..ad0d53b9508 100644 --- a/lib/spack/spack/test/stage.py +++ b/lib/spack/spack/test/stage.py @@ -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", [