Fix splicing related unit tests (#46914)

Some assertion are not testing DAG invariants, and they are passing only
because of the simple structure of the builtin.mock repository on develop.

Signed-off-by: Massimiliano Culpo <massimiliano.culpo@gmail.com>
This commit is contained in:
Massimiliano Culpo 2024-10-12 02:25:41 +02:00 committed by GitHub
parent e187508485
commit d5966e676d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 5 deletions

View File

@ -833,7 +833,8 @@ def test_lockfile_spliced_specs(environment_from_manifest, install_mockery):
# The one spec is mpileaks # The one spec is mpileaks
for _, spec in e2.concretized_specs(): for _, spec in e2.concretized_specs():
assert spec.spliced assert spec.spliced
assert spec["mpi"].satisfies(zmpi) assert spec["mpi"].satisfies(f"zmpi@{zmpi.version}")
assert spec["mpi"].build_spec.satisfies(zmpi)
def test_init_from_lockfile(environment_from_manifest): def test_init_from_lockfile(environment_from_manifest):

View File

@ -2295,8 +2295,9 @@ def test_explicit_splices(
spec = spack.spec.Spec("hdf5 ^zmpi").concretized() spec = spack.spec.Spec("hdf5 ^zmpi").concretized()
assert spec.satisfies(f"^mpich/{mpich_spec.dag_hash()}") assert spec.satisfies(f"^mpich@{mpich_spec.version}")
assert spec.build_spec.dependencies(name="zmpi", deptype="link") assert spec.build_spec.dependencies(name="zmpi", deptype="link")
assert spec["mpi"].build_spec.satisfies(mpich_spec)
assert not spec.build_spec.satisfies(f"^mpich/{mpich_spec.dag_hash()}") assert not spec.build_spec.satisfies(f"^mpich/{mpich_spec.dag_hash()}")
assert not spec.dependencies(name="zmpi", deptype="link") assert not spec.dependencies(name="zmpi", deptype="link")

View File

@ -967,7 +967,7 @@ def test_install_fail_on_interrupt(install_mockery, mock_fetch, monkeypatch):
"""Test ctrl-c interrupted install.""" """Test ctrl-c interrupted install."""
spec_name = "pkg-a" spec_name = "pkg-a"
err_msg = "mock keyboard interrupt for {0}".format(spec_name) err_msg = "mock keyboard interrupt for {0}".format(spec_name)
installer = create_installer([spec_name], {}) installer = create_installer([spec_name], {"fake": True})
setattr(inst.PackageInstaller, "_real_install_task", inst.PackageInstaller._install_task) setattr(inst.PackageInstaller, "_real_install_task", inst.PackageInstaller._install_task)
# Raise a KeyboardInterrupt error to trigger early termination # Raise a KeyboardInterrupt error to trigger early termination
monkeypatch.setattr(inst.PackageInstaller, "_install_task", _interrupt) monkeypatch.setattr(inst.PackageInstaller, "_install_task", _interrupt)
@ -997,7 +997,7 @@ def _install_fail_my_build_exception(installer, task, install_status, **kwargs):
def test_install_fail_single(install_mockery, mock_fetch, monkeypatch): def test_install_fail_single(install_mockery, mock_fetch, monkeypatch):
"""Test expected results for failure of single package.""" """Test expected results for failure of single package."""
installer = create_installer(["pkg-a"], {}) installer = create_installer(["pkg-a"], {"fake": True})
# Raise a KeyboardInterrupt error to trigger early termination # Raise a KeyboardInterrupt error to trigger early termination
monkeypatch.setattr(inst.PackageInstaller, "_install_task", _install_fail_my_build_exception) monkeypatch.setattr(inst.PackageInstaller, "_install_task", _install_fail_my_build_exception)
@ -1012,7 +1012,7 @@ def test_install_fail_single(install_mockery, mock_fetch, monkeypatch):
def test_install_fail_multi(install_mockery, mock_fetch, monkeypatch): def test_install_fail_multi(install_mockery, mock_fetch, monkeypatch):
"""Test expected results for failure of multiple packages.""" """Test expected results for failure of multiple packages."""
installer = create_installer(["pkg-a", "pkg-c"], {}) installer = create_installer(["pkg-a", "pkg-c"], {"fake": True})
# Raise a KeyboardInterrupt error to trigger early termination # Raise a KeyboardInterrupt error to trigger early termination
monkeypatch.setattr(inst.PackageInstaller, "_install_task", _install_fail_my_build_exception) monkeypatch.setattr(inst.PackageInstaller, "_install_task", _install_fail_my_build_exception)