Compare commits
3 Commits
develop
...
bugfix/con
Author | SHA1 | Date | |
---|---|---|---|
![]() |
55cc228307 | ||
![]() |
0df5b8616c | ||
![]() |
ced6f984ea |
@ -672,11 +672,12 @@ def set(self, path: str, value: Any, scope: Optional[str] = None) -> None:
|
|||||||
return
|
return
|
||||||
|
|
||||||
parts = process_config_path(path)
|
parts = process_config_path(path)
|
||||||
section = parts.pop(0)
|
section = parts[0]
|
||||||
|
|
||||||
section_data = self.get_config(section, scope=scope)
|
section_data = self.get_config(section, scope=scope)
|
||||||
|
|
||||||
data = section_data
|
full_data = {section: section_data}
|
||||||
|
data = full_data
|
||||||
while len(parts) > 1:
|
while len(parts) > 1:
|
||||||
key = parts.pop(0)
|
key = parts.pop(0)
|
||||||
|
|
||||||
@ -699,7 +700,7 @@ def set(self, path: str, value: Any, scope: Optional[str] = None) -> None:
|
|||||||
# update new value
|
# update new value
|
||||||
data[parts[0]] = value
|
data[parts[0]] = value
|
||||||
|
|
||||||
self.update_config(section, section_data, scope=scope)
|
self.update_config(section, full_data[section], scope=scope)
|
||||||
|
|
||||||
def __iter__(self):
|
def __iter__(self):
|
||||||
"""Iterate over scopes in this configuration."""
|
"""Iterate over scopes in this configuration."""
|
||||||
|
@ -176,13 +176,14 @@ def _resolve_paths(candidates):
|
|||||||
|
|
||||||
# Cached stage path root
|
# Cached stage path root
|
||||||
_stage_root = None
|
_stage_root = None
|
||||||
|
_default_stage_config = ["$tmpdir/$user/spack-stage", "$user_cache_path/stage"]
|
||||||
|
|
||||||
|
|
||||||
def get_stage_root():
|
def get_stage_root():
|
||||||
global _stage_root
|
global _stage_root
|
||||||
|
|
||||||
if _stage_root is None:
|
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):
|
if isinstance(candidates, str):
|
||||||
candidates = [candidates]
|
candidates = [candidates]
|
||||||
|
|
||||||
|
@ -1208,8 +1208,16 @@ def test_internal_config_list_override(mock_low_high_config, write_config_file):
|
|||||||
def test_set_section_override(mock_low_high_config, write_config_file):
|
def test_set_section_override(mock_low_high_config, write_config_file):
|
||||||
write_config_file("config", config_merge_list, "low")
|
write_config_file("config", config_merge_list, "low")
|
||||||
wanted_list = config_override_list["config"]["build_stage:"]
|
wanted_list = config_override_list["config"]["build_stage:"]
|
||||||
|
|
||||||
|
# Ensure test validity:
|
||||||
|
assert wanted_list != mock_low_high_config.get("config:build_stage")
|
||||||
|
|
||||||
|
# Test both bare section with full value and section override in path
|
||||||
with spack.config.override("config::build_stage", wanted_list):
|
with spack.config.override("config::build_stage", wanted_list):
|
||||||
assert mock_low_high_config.get("config:build_stage") == wanted_list
|
assert mock_low_high_config.get("config:build_stage") == wanted_list
|
||||||
|
with spack.config.override("config::", {"build_stage": wanted_list}):
|
||||||
|
assert mock_low_high_config.get("config:build_stage") == wanted_list
|
||||||
|
|
||||||
assert config_merge_list["config"]["build_stage"] == mock_low_high_config.get(
|
assert config_merge_list["config"]["build_stage"] == mock_low_high_config.get(
|
||||||
"config:build_stage"
|
"config:build_stage"
|
||||||
)
|
)
|
||||||
|
@ -754,6 +754,18 @@ def test_get_stage_root_bad_path(self, clear_stage_root):
|
|||||||
# Make sure the cached stage path values are unchanged.
|
# Make sure the cached stage path values are unchanged.
|
||||||
assert spack.stage._stage_root is None
|
assert spack.stage._stage_root is None
|
||||||
|
|
||||||
|
def test_get_stage_root_empty(self, clear_stage_root, monkeypatch, tmpdir):
|
||||||
|
expected = str(tmpdir)
|
||||||
|
monkeypatch.setattr(spack.stage, "_default_stage_config", [expected])
|
||||||
|
# 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
|
||||||
|
with spack.config.override("config::", {}):
|
||||||
|
assert spack.stage.get_stage_root() == expected
|
||||||
|
|
||||||
@pytest.mark.parametrize(
|
@pytest.mark.parametrize(
|
||||||
"path,purged",
|
"path,purged",
|
||||||
[
|
[
|
||||||
|
Loading…
Reference in New Issue
Block a user