Remove dead pre-Chef-15 branches from the monkey patches#41
Open
tas50 wants to merge 1 commit into
Open
Conversation
The gemspec requires chef >= 17, which makes several version-conditional
branches in the extension monkey patches unreachable:
- lwrp_base.rb guarded on `defined?(Chef::Provider::InlineResources)`,
which Chef removed in 13.0; only the >= 13 branch can run now.
- provider.rb and shell_out.rb (both modules) branched on
HAS_SHELLOUT_COMPACTED ("> 14.2"); at chef >= 17 the legacy `shell_out`
fallbacks are dead, so only the `shell_out_compacted` hooks remain.
- stubs_for.rb chose the hook method via the same always-true check.
Drop the dead branches and the now-unused HAS_SHELLOUT_COMPACTED
constant. Behavior is unchanged on supported Chef versions.
Signed-off-by: Tim Smith <tsmith84@proton.me>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The gemspec requires
chef >= 17, which makes several version-conditional branches inside the extension monkey patches permanently unreachable. This removes that dead code, simplifying the most version-fragile part of ChefSpec.What was dead, and why
extensions/chef/lwrp_base.rbbranched ondefined?(Chef::Provider::InlineResources).InlineResourceswas removed in Chef 13.0 (the code's ownelse # >= 13.0comment notes this), so at Chef ≥ 17 only thecompile_and_converge_actionbranch can run.extensions/chef/provider.rbandextensions/chef/shell_out.rb(bothResourceShellOutandMixinShellOut) branched onHAS_SHELLOUT_COMPACTED = Gem::Requirement.create("> 14.2"). At Chef ≥ 17 that's always satisfied, so the legacyshell_outfallbacks are dead and only theshell_out_compactedhooks remain.api/stubs_for.rbselected the hook method with the same always-true check, and defined the now-unusedHAS_SHELLOUT_COMPACTEDconstant.Changes
HAS_SHELLOUT_COMPACTEDconstant.Testing
bundle exec rspec spec/unit/→162 examples, 0 failures.stubs_for+execute(driveshell_out_compacted) →41 examples, 0 failures.custom_resource,custom_resource_block,heavy_provider_light_resource(drivecompile_and_converge_action) →7 examples, 0 failures.cookstyle --chefstyle -c .rubocop.ymlon the changed files → no offenses.