multi and single tests

This commit is contained in:
kshea21 2025-01-08 10:23:04 -08:00 committed by Gregory Becker
parent 5d7ba48b36
commit 11572c0caf
No known key found for this signature in database
GPG Key ID: 2362541F6D14ED84

View File

@ -982,24 +982,26 @@ class MyBuildException(Exception):
pass
_old_complete_task = None
def _install_fail_my_build_exception(installer, task, install_status, **kwargs):
if task.pkg.name == "pkg-a":
print("Raising MyBuildException for pkg-a")
raise MyBuildException("mock internal package build error for pkg-a")
else:
# No need for more complex logic here because no splices
print("starting process for {task.pkg.name}")
task.start_task(task)
installer._update_installed(task)
_old_complete_task(installer, task, install_status)
def test_install_fail_single(install_mockery, mock_fetch, monkeypatch):
"""Test expected results for failure of single package."""
global _old_complete_task
installer = create_installer(["pkg-a"], {"fake": True})
# Raise a KeyboardInterrupt error to trigger early termination
_old_complete_task = inst.PackageInstaller._complete_task
monkeypatch.setattr(inst.PackageInstaller, "_complete_task", _install_fail_my_build_exception)
with pytest.raises(MyBuildException, match="mock internal package build error for pkg-a"):
installer.install()
@ -1010,9 +1012,11 @@ def test_install_fail_single(install_mockery, mock_fetch, monkeypatch):
def test_install_fail_multi(install_mockery, mock_fetch, monkeypatch):
"""Test expected results for failure of multiple packages."""
global _old_complete_task
installer = create_installer(["pkg-a", "pkg-c"], {"fake": True})
# Raise a KeyboardInterrupt error to trigger early termination
_old_complete_task = inst.PackageInstaller._complete_task
monkeypatch.setattr(inst.PackageInstaller, "_complete_task", _install_fail_my_build_exception)
with pytest.raises(spack.error.InstallError, match="Installation request failed"):