Skip to content

Cover that the CLI actually builds the core cache - #131

Draft
apiology wants to merge 3 commits into
masterfrom
fix-gems-core
Draft

apiology wants to merge 3 commits into
masterfrom
fix-gems-core

Conversation

@apiology

Copy link
Copy Markdown
Owner

This PR was written by Claude Code on behalf of @apiology.

Carried on the fork after castwide#1346 was closed as not planned, in favour of castwide#1369, now merged. The lib fix is genuinely superseded and has been dropped; what survives is the spec.

Problem: nothing asserts that solargraph cache core builds the core cache. The neighbouring example only asserts it does not raise, which a no-op satisfies.

it 'caches core without erroring out' do
  skip 'WIP'
  ...
  expect { shell.cache('core') }.not_to raise_error
end

Solution: one example driving shell.cache('core') and asserting Collection::Core.load is reached.

The original crash — PinCache.cache_core named a method that was only dynamically defined — is gone, because 1369 replaced that call with Collection::Core.load. Net diff against master is spec/shell_spec.rb, 8 lines added, no lib change.

Shell#gems called PinCache.cache_core, which does not exist, so
`solargraph gems core` died with a NoMethodError before caching
anything. cache_core is defined on RbsMap::CoreMap, so call it there.
PinCache only computes cache paths and serializes, and RbsMap::CoreMap
already depends on it, so delegating from PinCache would make that
dependency circular.

The @sg-ignore above the call claimed cache_core and core? were
dynamically defined. pin_cache.rb has no method_missing or
define_method, and core? exists nowhere, so the comment and the
commented-out `if !PinCache.core?` guard go with it.

The "caches core without erroring out" example sat under `describe
'gems'` but called shell.cache('core'), which takes the gem-lookup
path and never reached this line. It now calls shell.gems('core')
with RbsMap::CoreMap stubbed.
The previous commit rewrote `caches core without erroring out` rather than
adding to it, dropping the coverage it gave `uncache core` and
`cache core`. Put that example back as it was and keep the new assertion
as its own example.

Only the new one depends on the fix: reverting the lib change leaves the
restored example passing and fails just `caches core pins from the gems
command`.
The crash this branch fixed is gone: 1369 replaced the dynamically
defined PinCache.cache_core with Collection::Core.load, so the lib
change is superseded and shell.rb takes master's side whole.

The spec is the part worth keeping. Master consolidated gems into
cache, and gems survives only as a Thor alias rather than a Ruby
method, so the example now drives shell.cache and asserts against
Collection::Core.load. It guards that the CLI actually builds the
core cache, which the neighbouring skipped example only asserts by
not raising.
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.

1 participant