additional testing
This commit is contained in:
parent
24dad071d4
commit
ae3a5f3848
@ -3320,3 +3320,28 @@ def test_view_update_mismatch(update_method, tmpdir, install_mockery, mock_fetch
|
|||||||
|
|
||||||
with pytest.raises(RuntimeError, match=checker):
|
with pytest.raises(RuntimeError, match=checker):
|
||||||
view.regenerate([spec])
|
view.regenerate([spec])
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("update_method", ["symlink", "exchange"])
|
||||||
|
def test_view_update_fails(update_method, tmpdir, install_mockery, mock_fetch, monkeypatch):
|
||||||
|
root = str(tmpdir.join("root"))
|
||||||
|
view = ev.environment.ViewDescriptor(
|
||||||
|
base_path=str(tmpdir), root=root, update_method=update_method
|
||||||
|
)
|
||||||
|
|
||||||
|
spec = spack.spec.Spec("libelf").concretized()
|
||||||
|
install("libelf")
|
||||||
|
|
||||||
|
def raises(*args, **kwargs):
|
||||||
|
raise OSError
|
||||||
|
|
||||||
|
monkeypatch.setattr(fs, "rename", raises)
|
||||||
|
monkeypatch.setattr(spack.util.atomic_update, "_renameat2", raises)
|
||||||
|
|
||||||
|
with pytest.raises(OSError):
|
||||||
|
view.regenerate([spec])
|
||||||
|
|
||||||
|
assert not os.path.exists(view.root)
|
||||||
|
if update_method == "symlink":
|
||||||
|
link = os.path.join(str(tmpdir), "._root", "._tmp_symlink")
|
||||||
|
assert not os.path.lexists(link)
|
||||||
|
@ -59,6 +59,7 @@ def atomic_update_renameat2(src, dest):
|
|||||||
except (OSError, IOError):
|
except (OSError, IOError):
|
||||||
if not dest_exists:
|
if not dest_exists:
|
||||||
os.unlink(dest)
|
os.unlink(dest)
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
def atomic_update_symlink(src, dest):
|
def atomic_update_symlink(src, dest):
|
||||||
@ -71,6 +72,6 @@ def atomic_update_symlink(src, dest):
|
|||||||
# atomically mv the symlink to destpath (still points to srcpath)
|
# atomically mv the symlink to destpath (still points to srcpath)
|
||||||
try:
|
try:
|
||||||
fs.rename(tmp_symlink_name, dest)
|
fs.rename(tmp_symlink_name, dest)
|
||||||
except Exception:
|
except OSError:
|
||||||
os.unlink(tmp_symlink_name)
|
os.unlink(tmp_symlink_name)
|
||||||
raise
|
raise
|
||||||
|
Loading…
Reference in New Issue
Block a user