Add unit-tests back
This commit is contained in:
parent
29fbad20a2
commit
36bf6c9009
@ -3236,3 +3236,20 @@ def test_relative_view_path_on_command_line_is_made_absolute(tmpdir, config):
|
||||
env("create", "--with-view", "view", "--dir", "env")
|
||||
environment = ev.Environment(os.path.join(".", "env"))
|
||||
assert os.path.samefile("view", environment.default_view.root)
|
||||
|
||||
|
||||
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)
|
||||
|
||||
dir_name = "user_env"
|
||||
env("create", dir_name)
|
||||
out = env("list")
|
||||
|
||||
assert dir_name in out
|
||||
assert env_dir in ev.root(dir_name)
|
||||
assert os.path.isdir(os.path.join(env_dir, dir_name))
|
||||
|
@ -143,3 +143,21 @@ def test_user_view_path_is_not_canonicalized_in_yaml(tmpdir, config):
|
||||
snd = ev.Environment(env_path)
|
||||
assert snd.yaml["spack"]["view"] == view
|
||||
assert os.path.samefile(snd.default_view.root, absolute_view)
|
||||
|
||||
|
||||
def test_environment_cant_modify_environments_root(tmpdir):
|
||||
filename = str(tmpdir.join("spack.yaml"))
|
||||
with open(filename, "w") as f:
|
||||
f.write(
|
||||
"""\
|
||||
spack:
|
||||
config:
|
||||
environments_root: /a/black/hole
|
||||
view: false
|
||||
specs: []
|
||||
"""
|
||||
)
|
||||
with tmpdir.as_cwd():
|
||||
with pytest.raises(ev.SpackEnvironmentError):
|
||||
e = ev.Environment(tmpdir.strpath)
|
||||
ev.activate(e)
|
||||
|
Loading…
Reference in New Issue
Block a user