Remove constraint on environments_root creation
This commit is contained in:
parent
663967d984
commit
9b6a109c7e
@ -261,17 +261,7 @@ def read(name):
|
||||
def create(name, init_file=None, with_view=None, keep_relative=False):
|
||||
"""Create a named environment in Spack."""
|
||||
if not os.path.isdir(env_root_path()):
|
||||
# double check that the root path exists before we check the full environment name
|
||||
# we need to be a bit more pedantic and not create automatically since this is a user
|
||||
# configurable path that can be subject to user input errors
|
||||
if env_root_path() == default_env_path:
|
||||
# we can just create the default path since it is internal to spack
|
||||
os.mkdir(default_env_path)
|
||||
else:
|
||||
raise SpackEnvironmentError(
|
||||
"The environments_root '{er}' does not exist. Please create the directory or "
|
||||
"provide a valid path in the config.yaml".format(er=env_root_path())
|
||||
)
|
||||
os.mkdir(env_root_path())
|
||||
validate_env_name(name)
|
||||
if exists(name):
|
||||
raise SpackEnvironmentError("'%s': environment already exists" % name)
|
||||
|
@ -3183,17 +3183,6 @@ def test_env_include_packages_url(
|
||||
assert "openmpi" in cfg["all"]["providers"]["mpi"]
|
||||
|
||||
|
||||
def test_config_file_read_invalid_yaml(tmpdir, mutable_empty_config):
|
||||
"""Test reading a configuration file with invalid (unparseable) YAML
|
||||
raises a ConfigFileError."""
|
||||
filename = tmpdir.join("test.yaml")
|
||||
with open(filename, "w") as f:
|
||||
f.write("spack:\nview")
|
||||
|
||||
with pytest.raises(spack.config.ConfigFileError, match="parsing yaml"):
|
||||
spack.config.read_config_file(filename)
|
||||
|
||||
|
||||
def test_environment_created_in_users_location(mutable_config, tmpdir):
|
||||
"""Test that an environment is created in a location based on the config"""
|
||||
spack.config.set("config:environments_root", str(tmpdir.join("envs")))
|
||||
@ -3202,21 +3191,9 @@ def test_environment_created_in_users_location(mutable_config, tmpdir):
|
||||
assert tmpdir.strpath in env_dir
|
||||
assert not os.path.isdir(env_dir)
|
||||
|
||||
os.makedirs(env_dir)
|
||||
env("create", "test")
|
||||
out = env("list")
|
||||
|
||||
assert "test" in out
|
||||
assert env_dir in ev.root("test")
|
||||
assert os.path.isdir(os.path.join(env_dir, "test"))
|
||||
|
||||
|
||||
def test_environment_errors_if_root_missing(mutable_config, tmpdir):
|
||||
spack.config.set("config:environments_root", str(tmpdir.join("envs")))
|
||||
env_dir = spack.config.get("config:environments_root")
|
||||
|
||||
assert tmpdir.strpath in env_dir
|
||||
assert not os.path.isdir(env_dir)
|
||||
|
||||
with pytest.raises(ev.SpackEnvironmentError, match=env_dir):
|
||||
env("create", "test")
|
||||
|
@ -30,9 +30,6 @@
|
||||
import spack.schema.repos
|
||||
import spack.util.path as spack_path
|
||||
import spack.util.spack_yaml as syaml
|
||||
from spack.main import SpackCommand
|
||||
|
||||
env = SpackCommand("env")
|
||||
|
||||
# sample config data
|
||||
config_low = {
|
||||
@ -1451,3 +1448,14 @@ def test_config_file_read_perms_failure(tmpdir, mutable_empty_config):
|
||||
|
||||
with pytest.raises(spack.config.ConfigFileError, match="not readable"):
|
||||
spack.config.read_config_file(filename)
|
||||
|
||||
|
||||
def test_config_file_read_invalid_yaml(tmpdir, mutable_empty_config):
|
||||
"""Test reading a configuration file with invalid (unparseable) YAML
|
||||
raises a ConfigFileError."""
|
||||
filename = tmpdir.join("test.yaml")
|
||||
with open(filename, "w") as f:
|
||||
f.write("spack:\nview")
|
||||
|
||||
with pytest.raises(spack.config.ConfigFileError, match="parsing yaml"):
|
||||
spack.config.read_config_file(filename)
|
||||
|
Loading…
Reference in New Issue
Block a user