Address reviewer comments

This commit is contained in:
psakiev 2022-12-07 14:25:12 -07:00
parent 3e07eb8cf0
commit f7b4993810
3 changed files with 40 additions and 40 deletions

View File

@ -3181,3 +3181,42 @@ def test_env_include_packages_url(
cfg = spack.config.get("packages")
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 = join_path(tmpdir.strpath, "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")))
env_dir = spack.config.get("config:environments_root")
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")

View File

@ -1451,42 +1451,3 @@ 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 = join_path(tmpdir.strpath, "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")))
env_dir = spack.config.get("config:environments_root")
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")

View File

@ -1527,7 +1527,7 @@ def get_rev():
@pytest.fixture()
def mutable_mock_env_path(tmpdir_factory):
def mutable_mock_env_path(tmpdir_factory, mutable_config):
"""Fixture for mocking the internal spack environments directory."""
saved_path = ev.environment.default_env_path
mock_path = tmpdir_factory.mktemp("mock-env-path")