Skip to content

Fixed simulate diff mode not reporting a removal with a version - #6412

Open
djbclark wants to merge 1 commit into
cfengine:masterfrom
djbclark:fix/simulate-pkg-removal-with-version
Open

djbclark wants to merge 1 commit into
cfengine:masterfrom
djbclark:fix/simulate-pkg-removal-with-version

Conversation

@djbclark

Copy link
Copy Markdown
Contributor

--simulate=diff dropped a removal with a version unless it cancelled a recorded install of the same version. The else branch meant for "a different version of this package is about to be installed" also caught the common case where nothing was recorded as installed, so removing version 1.0 of a present package vanished from the diff report while --simulate=manifest still said "would be absent". One-line fix (else → else if (inst_record != NULL)), a regression test that fails without it, and a test for the case the branch still covers:

$ tests/unit/simulate_mode_test      # without the fix
ERROR: simulate_mode_test.c:114 Failure!
test_diff_removal_with_version: Test failed.
1 out of 5 tests failed!
$ tests/unit/simulate_mode_test      # with the fix
All 5 tests passed

Fork CI: djbclark#44

AI-assisted. I can't vouch for the C syntax beyond a basic level, but I did look at the logic and it seemed sound.

🤖 Generated with Claude Code

@larsewi larsewi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks 🚀 Could you change it to use StringContains()? It reads a bit better.

Comment thread tests/unit/simulate_mode_test.c Outdated
Comment thread tests/unit/simulate_mode_test.c Outdated
A recorded removal with a version was only reported when it cancelled a
recorded installation of the same version.

Ticket: none
Changelog: Title
Signed-off-by: Daniel JB Clark <djbclark@gmail.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@djbclark
djbclark force-pushed the fix/simulate-pkg-removal-with-version branch from 086d277 to eb6cf5f Compare October 16, 2026 15:45
@larsewi

larsewi commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@cf-bottom Jenkins please :)

@cf-bottom

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants