spack -e x config --scope=y add z
add to scope (#31746)
* `spack -e x config --scope=y add z` add to scope instead of to the environment file.
This commit is contained in:
parent
2b680ae7b8
commit
707a099b69
2 changed files with 9 additions and 1 deletions
|
@ -120,7 +120,7 @@ def _get_scope_and_section(args):
|
|||
path = getattr(args, "path", None)
|
||||
|
||||
# w/no args and an active environment, point to env manifest
|
||||
if not section:
|
||||
if not section and not scope:
|
||||
env = ev.active_environment()
|
||||
if env:
|
||||
scope = env.env_file_config_scope_name()
|
||||
|
|
|
@ -118,6 +118,14 @@ def test_config_edit_edits_spack_yaml(mutable_mock_env_path):
|
|||
assert config("edit", "--print-file").strip() == env.manifest_path
|
||||
|
||||
|
||||
def test_config_add_with_scope_adds_to_scope(mutable_config, mutable_mock_env_path):
|
||||
"""Test adding to non-env config scope with an active environment"""
|
||||
env = ev.create("test")
|
||||
with env:
|
||||
config("--scope=user", "add", "config:install_tree:root:/usr")
|
||||
assert spack.config.get("config:install_tree:root", scope="user") == "/usr"
|
||||
|
||||
|
||||
def test_config_edit_fails_correctly_with_no_env(mutable_mock_env_path):
|
||||
output = config("edit", "--print-file", fail_on_error=False)
|
||||
assert "requires a section argument or an active environment" in output
|
||||
|
|
Loading…
Reference in a new issue