utils/cpan: add offline test coverage - #23527
Merged
Merged
Conversation
Signed-off-by: Patrick Linnane <patrick@linnane.io>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds comprehensive offline RSpec coverage for utils/cpan.rb, focusing on the previously untested MetaCPAN fetch path and the formula resource stanza rewrite/update logic, by stubbing Utils::Curl.curl_output to avoid any network access.
Changes:
- Add offline specs for
CPAN::Package#latest_cpan_info, covering success, caching, and multiple failure/malformed-data cases. - Add offline specs for
CPAN.update_perl_resources!, covering print-only output, in-place formula rewrite, version/update reporting, and error/--ignore-errorsbehavior.
馃挕 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.
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.
utils/cpan.rbwas almost entirely untested: the existing spec covered URL version parsing andvalid_cpan_package?, and nothing else. Every path that talks to MetaCPAN or rewrites a formula had no coverage at all.This adds offline coverage for
CPAN::Package#latest_cpan_info(success, per-instance caching, non-CPAN short circuit, HTTP failure, malformed JSON, missingdownload_url, missingchecksum_sha256) and forCPAN.update_perl_resources!(print-only output, in-place AST rewrite, version reporting, already-current resources, no CPAN resources, unresolvable metadata, and the--ignore-errorswrite path).Utils::Curl.curl_outputis stubbed throughout so nothing hits the network, unlike the equivalent PyPI coverage inpypi_spec.rbwhich is gated behind:needs_network.I want this in before touching
utils/cpan.rbitself. Two production issues are already known: non-CPAN resources adjacent to CPAN ones are silently dropped during the resource-block rewrite, and a MetaCPAN response missingversionproduces an array containingnildespite the declaredT::Array[String]return type. Both need behavior changes, and those are easier to review against a spec that already pins the current contract.brewcommands to reproduce the bug?brew lgtm(style, typechecking and tests) locally?Claude Code (Opus 5) drafted the tests; I reviewed the diff, verified each new example fails against a mutated implementation and passes against the real one, and ran
brew lgtmplus targeted specs.