diff options
author | Harmen Stoppels <harmenstoppels@gmail.com> | 2022-08-23 21:52:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-23 12:52:34 -0700 |
commit | 707a099b69ff5cf56fb10264efa785bb6f5c9ff7 (patch) | |
tree | b9bebd2e67a656b4fbc2fbbfffada0afbe741d27 /lib | |
parent | 2b680ae7b8de9fcbf9f276dc24bf93b741c20f49 (diff) | |
download | spack-707a099b69ff5cf56fb10264efa785bb6f5c9ff7.tar.gz spack-707a099b69ff5cf56fb10264efa785bb6f5c9ff7.tar.bz2 spack-707a099b69ff5cf56fb10264efa785bb6f5c9ff7.tar.xz spack-707a099b69ff5cf56fb10264efa785bb6f5c9ff7.zip |
`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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/spack/spack/cmd/config.py | 2 | ||||
-rw-r--r-- | lib/spack/spack/test/cmd/config.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/spack/spack/cmd/config.py b/lib/spack/spack/cmd/config.py index f36dffd40a..06f6477dfd 100644 --- a/lib/spack/spack/cmd/config.py +++ b/lib/spack/spack/cmd/config.py @@ -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() diff --git a/lib/spack/spack/test/cmd/config.py b/lib/spack/spack/test/cmd/config.py index f9c3fae2f9..cdf9bc00a0 100644 --- a/lib/spack/spack/test/cmd/config.py +++ b/lib/spack/spack/test/cmd/config.py @@ -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 |