failing overwrite build deps

This commit is contained in:
kshea21 2025-01-30 16:20:30 -08:00 committed by Gregory Becker
parent 974d10f32b
commit 2da51eaec7
No known key found for this signature in database
GPG Key ID: 2362541F6D14ED84

View File

@ -727,7 +727,7 @@ def test_installing_task_use_cache(install_mockery, monkeypatch):
task = create_build_task(request.pkg) task = create_build_task(request.pkg)
monkeypatch.setattr(inst, "_install_from_cache", _true) monkeypatch.setattr(inst, "_install_from_cache", _true)
installer._complete_task(task, None) installer.install()
assert request.pkg_id in installer.installed assert request.pkg_id in installer.installed
@ -907,14 +907,16 @@ def test_update_failed_no_dependent_task(install_mockery):
def test_install_uninstalled_deps(install_mockery, monkeypatch, capsys): def test_install_uninstalled_deps(install_mockery, monkeypatch, capsys):
"""Test install with uninstalled dependencies.""" """Test install with uninstalled dependencies."""
installer = create_installer(["dependent-install"], {}) installer = create_installer(["parallel-package-a"], {})
# Skip the actual installation and any status updates # Skip the actual installation and any status updates
monkeypatch.setattr(inst.PackageInstaller, "_complete_task", _noop) monkeypatch.setattr(inst.Task, "start", _noop)
monkeypatch.setattr(inst.Task, "poll", _noop)
monkeypatch.setattr(inst.Task, "complete", _noop)
monkeypatch.setattr(inst.PackageInstaller, "_update_installed", _noop) monkeypatch.setattr(inst.PackageInstaller, "_update_installed", _noop)
monkeypatch.setattr(inst.PackageInstaller, "_update_failed", _noop) monkeypatch.setattr(inst.PackageInstaller, "_update_failed", _noop)
msg = "Cannot proceed with dependency-install" msg = "Cannot proceed with parallel-package-a"
with pytest.raises(spack.error.InstallError, match=msg): with pytest.raises(spack.error.InstallError, match=msg):
installer.install() installer.install()
@ -924,7 +926,7 @@ def test_install_uninstalled_deps(install_mockery, monkeypatch, capsys):
def test_install_failed(install_mockery, monkeypatch, capsys): def test_install_failed(install_mockery, monkeypatch, capsys):
"""Test install with failed install.""" """Test install with failed install."""
installer = create_installer(["pkg-b"], {}) installer = create_installer(["parallel-package-a"], {})
# Make sure the package is identified as failed # Make sure the package is identified as failed
monkeypatch.setattr(spack.database.FailureTracker, "has_failed", _true) monkeypatch.setattr(spack.database.FailureTracker, "has_failed", _true)
@ -939,7 +941,7 @@ def test_install_failed(install_mockery, monkeypatch, capsys):
def test_install_failed_not_fast(install_mockery, monkeypatch, capsys): def test_install_failed_not_fast(install_mockery, monkeypatch, capsys):
"""Test install with failed install.""" """Test install with failed install."""
installer = create_installer(["pkg-a"], {"fail_fast": False}) installer = create_installer(["parallel-package-a"], {"fail_fast": False})
# Make sure the package is identified as failed # Make sure the package is identified as failed
monkeypatch.setattr(spack.database.FailureTracker, "has_failed", _true) monkeypatch.setattr(spack.database.FailureTracker, "has_failed", _true)
@ -949,7 +951,7 @@ def test_install_failed_not_fast(install_mockery, monkeypatch, capsys):
out = str(capsys.readouterr()) out = str(capsys.readouterr())
assert "failed to install" in out assert "failed to install" in out
assert "Skipping build of pkg-a" in out assert "Skipping build of parallel-package-a" in out
def _interrupt(installer, task, install_status, **kwargs): def _interrupt(installer, task, install_status, **kwargs):
@ -1030,22 +1032,30 @@ def test_install_fail_multi(install_mockery, mock_fetch, monkeypatch):
def test_install_fail_fast_on_detect(install_mockery, monkeypatch, capsys): def test_install_fail_fast_on_detect(install_mockery, monkeypatch, capsys):
"""Test fail_fast install when an install failure is detected.""" """Test fail_fast install when an install failure is detected."""
# Note: this test depends on the order of the installations a = spack.concretize.concretize_one("parallel-package-a")
b, c = spack.concretize.concretize_one("pkg-b"), spack.concretize.concretize_one("pkg-c")
b_id, c_id = inst.package_id(b), inst.package_id(c)
installer = create_installer([c, b], {"fail_fast": True}) a_id = inst.package_id(a)
b_id = inst.package_id(a["parallel-package-b"])
c_id = inst.package_id(a["parallel-package-c"])
installer = create_installer([a], {"fail_fast": True})
# Make sure all packages are identified as failed # Make sure all packages are identified as failed
# This will prevent b from installing, which will cause the build of c to be skipped. # This will prevent a and b from installing, which will cause the build of c to be skipped
# and the active processes to be killed.
monkeypatch.setattr(spack.database.FailureTracker, "has_failed", _true) monkeypatch.setattr(spack.database.FailureTracker, "has_failed", _true)
installer.max_active_tasks = 2
with pytest.raises(spack.error.InstallError, match="after first install failure"): with pytest.raises(spack.error.InstallError, match="after first install failure"):
installer.install() installer.install()
assert c_id in installer.failed assert b_id in installer.failed, "Expected b to be marked as failed"
assert b_id not in installer.failed, "Expected no attempt to install pkg-c" assert c_id in installer.failed, "Exepected c to be marked as failed"
assert f"{c_id} failed to install" in capsys.readouterr().err assert (
a_id not in installer.installed
), "Package a cannot install due to its dependencies failing"
# check that b's active process got killed when c failed
assert f"{b_id} failed to install" in capsys.readouterr().err
def _test_install_fail_fast_on_except_patch(installer, **kwargs): def _test_install_fail_fast_on_except_patch(installer, **kwargs):
@ -1197,15 +1207,14 @@ def test_overwrite_install_backup_success(temporary_store, config, mock_packages
# Get a build task. TODO: refactor this to avoid calling internal methods # Get a build task. TODO: refactor this to avoid calling internal methods
installer = create_installer(["pkg-c"]) installer = create_installer(["pkg-c"])
installer._init_queue() installer._init_queue()
task = installer._pop_task() task = installer._pop_ready_task()
# Make sure the install prefix exists with some trivial file # Make sure the install prefix exists with some trivial file
installed_file = os.path.join(task.pkg.prefix, "some_file") installed_file = os.path.join(task.pkg.prefix, "some_file")
fs.touchp(installed_file) fs.touchp(installed_file)
class InstallerThatWipesThePrefixDir: class InstallerThatWipesThePrefixDir:
# def install(): def install(self):
def _start_task(self, task, install_status):
shutil.rmtree(task.pkg.prefix, ignore_errors=True) shutil.rmtree(task.pkg.prefix, ignore_errors=True)
fs.mkdirp(task.pkg.prefix) fs.mkdirp(task.pkg.prefix)
raise Exception("Some fatal install error") raise Exception("Some fatal install error")
@ -1240,7 +1249,7 @@ def test_overwrite_install_backup_failure(temporary_store, config, mock_packages
# Note: this test relies on installing a package with no dependencies # Note: this test relies on installing a package with no dependencies
class InstallerThatAccidentallyDeletesTheBackupDir: class InstallerThatAccidentallyDeletesTheBackupDir:
def _complete_task(self, task, install_status): def install(self):
# Remove the backup directory, which is at the same level as the prefix, # Remove the backup directory, which is at the same level as the prefix,
# starting with .backup # starting with .backup
backup_glob = os.path.join( backup_glob = os.path.join(