Skip to content

Fix wrong hash in spliced specs, and improve unit-tests #48574

Merged
alalazo merged 17 commits intospack:developfrom
alalazo:maintainers/remove-code-duplication-in-abi-splicing-tests
Jan 15, 2025
Merged

Fix wrong hash in spliced specs, and improve unit-tests #48574
alalazo merged 17 commits intospack:developfrom
alalazo:maintainers/remove-code-duplication-in-abi-splicing-tests

Conversation

@alalazo
Copy link
Copy Markdown
Member

@alalazo alalazo commented Jan 14, 2025

fixes #48578

I did a minor clean-up of the unit-tests while reading the code related to splicing.

Modifications:

  • Fix a severe bug where a spliced spec has the same hash as the original build spec
  • Removed CacheManager in favor of install_mockery. The latter sets up a temporary store, and removes it at the end of the test, and is used everywhere else in the tests.
  • Deleted a couple of helper functions e.g. _has_dependencies
  • Used a more specific exception than Exception in tests
  • Extended, and renamed splicing_setup (now called install_specs)
  • Added more specific assertion than assert concretize_one(abstract).satisfies(abstract)

@spackbot-app spackbot-app bot added commands core PR affects Spack core functionality tests General test capability(ies) labels Jan 14, 2025
@alalazo
Copy link
Copy Markdown
Member Author

alalazo commented Jan 14, 2025

The PR is still a draft, partially because I think I found a bug, at least in the tests. Applying this diff:

diff --git a/lib/spack/spack/test/abi_splicing.py b/lib/spack/spack/test/abi_splicing.py
index 39cea68511..890d11099e 100644
--- a/lib/spack/spack/test/abi_splicing.py
+++ b/lib/spack/spack/test/abi_splicing.py
@@ -54,7 +54,8 @@ def test_spec_reuse(spec_str, install_specs, mutable_config):
 
 
 def test_splice_installed_hash(install_specs, mutable_config):
-    install_specs(
+    """Tests splicing the dependency of an installed spec, for another installed spec"""
+    splice_t, splice_h = install_specs(
         "splice-t@1 ^[email protected]+compat ^[email protected]",
         "[email protected]+compat ^[email protected]",
     )
@@ -64,8 +65,12 @@ def test_splice_installed_hash(install_specs, mutable_config):
     goal_spec = Spec("splice-t@1 ^[email protected]+compat ^[email protected]")
     with pytest.raises(SolverError):
         goal_spec.concretized()
+
     _enable_splicing()
-    assert goal_spec.concretized().satisfies(goal_spec)
+    concrete = goal_spec.concretized()
+    assert concrete.build_spec.satisfies(splice_t)
+    assert not concrete.satisfies(splice_t)
+    assert concrete["splice-h"].satisfies(splice_h)

the test_splice_installed_hash fails, since apparently splice_t and concrete have the same hash, which I think shouldn't be the case. The bug can be reproduced on develop in the same way. @becker33 @JohnGouwar Fyi

EDIT: See bug report #48578

@alalazo alalazo force-pushed the maintainers/remove-code-duplication-in-abi-splicing-tests branch from 9a54ef5 to fb205c7 Compare January 15, 2025 11:44
@alalazo alalazo changed the title Minor clean-up of abi_splicing unit tests Fix wrong hash in spliced specs, and improve unit-tests Jan 15, 2025
Copy link
Copy Markdown
Contributor

@JohnGouwar JohnGouwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes to the copy in splicing look good, there is just one change in test_double_splice that is needed to make the test pass.

@alalazo alalazo force-pushed the maintainers/remove-code-duplication-in-abi-splicing-tests branch from d7ccb89 to 7481d0b Compare January 15, 2025 16:05
@alalazo alalazo marked this pull request as ready for review January 15, 2025 17:13
@alalazo alalazo requested a review from JohnGouwar January 15, 2025 18:11
Copy link
Copy Markdown
Contributor

@JohnGouwar JohnGouwar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these changes look good to me; they definitely make the unit-tests better and cleaner. test_double_splice is having problems due to some instability in the topo ordering of multi-rooted specs, but that may be a deeper fix.

@alalazo alalazo merged commit 59a7195 into spack:develop Jan 15, 2025
@alalazo alalazo deleted the maintainers/remove-code-duplication-in-abi-splicing-tests branch January 15, 2025 18:44
@alalazo alalazo added the v0.23.1 PRs to backport for v0.23.1 label Jan 16, 2025
mtaillefumier pushed a commit to mtaillefumier/spack that referenced this pull request Jan 20, 2025
Modifications:
* Fix a severe bug where a spliced spec has the same hash as the original build spec
* Removed CacheManager in favor of install_mockery. The latter sets up a temporary store, and removes it at the end 
   of the test.
* Deleted a couple of helper functions e.g. _has_dependencies
* Checked that SolverException is raised, rather than Exception (more specific)
* Extended, and renamed the splicing_setup fixture (now called install_specs)
* Added more specific assertions in each test

One test is currently flaky, due to some instability when sorting multiple specs. It's currently marked xfail
@haampie
Copy link
Copy Markdown
Member

haampie commented Feb 3, 2025

This does not apply well for backporting, so i'm dropping it. Feel free to fix splicing for 0.23 by cherry-picking the relevant commits from develop and opening a PR against the backports/v0.23.1 branch.

@haampie haampie removed the v0.23.1 PRs to backport for v0.23.1 label Feb 3, 2025
teaguesterling pushed a commit to teaguesterling/spack that referenced this pull request Feb 5, 2025
Modifications:
* Fix a severe bug where a spliced spec has the same hash as the original build spec
* Removed CacheManager in favor of install_mockery. The latter sets up a temporary store, and removes it at the end 
   of the test.
* Deleted a couple of helper functions e.g. _has_dependencies
* Checked that SolverException is raised, rather than Exception (more specific)
* Extended, and renamed the splicing_setup fixture (now called install_specs)
* Added more specific assertions in each test

One test is currently flaky, due to some instability when sorting multiple specs. It's currently marked xfail
mrmundt pushed a commit to mrmundt/spack that referenced this pull request Feb 17, 2025
Modifications:
* Fix a severe bug where a spliced spec has the same hash as the original build spec
* Removed CacheManager in favor of install_mockery. The latter sets up a temporary store, and removes it at the end 
   of the test.
* Deleted a couple of helper functions e.g. _has_dependencies
* Checked that SolverException is raised, rather than Exception (more specific)
* Extended, and renamed the splicing_setup fixture (now called install_specs)
* Added more specific assertions in each test

One test is currently flaky, due to some instability when sorting multiple specs. It's currently marked xfail
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands core PR affects Spack core functionality tests General test capability(ies)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Original and spliced specs have the same hash

4 participants