Skip to content

utils/cpan: add offline test coverage - #23527

Merged
p-linnane merged 1 commit into
mainfrom
cpan-test-coverage
Aug 14, 2026
Merged

utils/cpan: add offline test coverage#23527
p-linnane merged 1 commit into
mainfrom
cpan-test-coverage

Conversation

@p-linnane

Copy link
Copy Markdown
Contributor

utils/cpan.rb was almost entirely untested: the existing spec covered URL version parsing and valid_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, missing download_url, missing checksum_sha256) and for CPAN.update_perl_resources! (print-only output, in-place AST rewrite, version reporting, already-current resources, no CPAN resources, unresolvable metadata, and the --ignore-errors write path). Utils::Curl.curl_output is stubbed throughout so nothing hits the network, unlike the equivalent PyPI coverage in pypi_spec.rb which is gated behind :needs_network.

I want this in before touching utils/cpan.rb itself. 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 missing version produces an array containing nil despite the declared T::Array[String] return type. Both need behavior changes, and those are easier to review against a spec that already pins the current contract.


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include Hyperfine benchmarks.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

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 lgtm plus targeted specs.


Signed-off-by: Patrick Linnane <patrick@linnane.io>
Copilot AI lite review requested due to automatic review settings August 14, 2026 16:35

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

Copilot AI 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.

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-errors behavior.

馃挕 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@p-linnane
p-linnane added this pull request to the merge queue Aug 14, 2026
Merged via the queue into main with commit a08db15 Aug 14, 2026
47 checks passed
@p-linnane
p-linnane deleted the cpan-test-coverage branch August 14, 2026 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants