Skip to content

test(vscode_parser): add unit tests for per-file summary cache LRU and explicit file_id (#807)#997

Merged
microsasa merged 2 commits intomainfrom
add-bounded-file-summary-cache-tests-762c6d9977749213
Apr 19, 2026
Merged

test(vscode_parser): add unit tests for per-file summary cache LRU and explicit file_id (#807)#997
microsasa merged 2 commits intomainfrom
add-bounded-file-summary-cache-tests-762c6d9977749213

Conversation

@microsasa
Copy link
Copy Markdown
Owner

Closes #807

Summary

Adds dedicated unit tests for two previously untested code paths in vscode_parser.py:

TestPerFileSummaryCacheLRU

Exercises lru_insert() with the exact types used by _PER_FILE_SUMMARY_CACHE (Path keys, _CachedFileSummary values):

  • test_insert_below_capacity — inserting fewer entries than max_size stores all of them
  • test_eviction_when_full — inserting max_size + 1 entries evicts the oldest (LRU) entry
  • test_update_existing_key_moves_to_mru — updating an existing key repositions it to the MRU end
  • test_update_existing_key_does_not_grow_cache — replacing an existing key keeps len(cache) unchanged

TestGetCachedVscodeRequestsExplicitFileId

Tests the file_id parameter path in _get_cached_vscode_requests:

  • test_none_file_id_populates_cache_with_none — passing file_id=None stores None as cached identity
  • test_none_to_real_file_id_invalidates_cache — a None → real (mtime_ns, size) transition is a cache miss and triggers re-parse
  • test_real_file_id_avoids_extra_stat_call — passing a pre-computed file_id bypasses safe_file_identity on cache hit

Verification

  • All 152 vscode_parser tests pass
  • Full test suite passes (1489/1490 — 1 pre-existing failure unrelated to this change)
  • pyright strict: 0 errors
  • ruff: all checks passed

Generated by Issue Implementer · ● 14.3M ·

…d explicit file_id

Add two new test classes to cover untested branches identified in #807:

- TestPerFileSummaryCacheLRU: exercises lru_insert with Path keys and
  _CachedFileSummary values, verifying insert below capacity, eviction
  when full, update moves to MRU position, and update does not grow cache.

- TestGetCachedVscodeRequestsExplicitFileId: tests the explicit file_id
  parameter path in _get_cached_vscode_requests, verifying that
  file_id=None populates cache with None, None→real id is a cache miss,
  and passing a real file_id avoids redundant safe_file_identity calls.

Closes #807

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsasa microsasa added the aw Created by agentic workflow label Apr 19, 2026
Copilot AI review requested due to automatic review settings April 19, 2026 07:05
@microsasa microsasa added the aw Created by agentic workflow label Apr 19, 2026
@microsasa microsasa enabled auto-merge April 19, 2026 07:05
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds targeted unit tests to improve coverage of VS Code log parser caching behavior in copilot_usage.vscode_parser, specifically around LRU eviction semantics and the explicit file_id fast-path for request caching.

Changes:

  • Add unit-level LRU tests exercising lru_insert() with the same key/value types used by the per-file summary cache.
  • Add dedicated tests for _get_cached_vscode_requests(..., file_id=...), including None identity handling and cache-hit behavior.

Comment thread tests/copilot_usage/test_vscode_parser.py
Comment thread tests/copilot_usage/test_vscode_parser.py Outdated
- Use stat_spy binding in first patch block (assert call_count == 1)
  to avoid Ruff F841 and document post-parse stat behavior
- Tighten weak assertion from 'cached.file_id == real_id or
  cached.file_id is not None' to 'cached.file_id == real_id'

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Commit pushed: fc43c8c

Generated by Review Responder

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@microsasa microsasa added the aw-quality-gate-approved Quality gate approved the PR label Apr 19, 2026
Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Low-impact test-only addition with good coverage. Adds 7 meaningful unit tests across two new test classes (TestPerFileSummaryCacheLRU and TestGetCachedVscodeRequestsExplicitFileId) exercising previously untested LRU eviction semantics and explicit file_id cache paths. No production code changes. All CI checks pass. Auto-approving for merge.

@microsasa microsasa merged commit b8ecaca into main Apr 19, 2026
10 checks passed
@microsasa microsasa deleted the add-bounded-file-summary-cache-tests-762c6d9977749213 branch April 19, 2026 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aw Created by agentic workflow aw-quality-gate-approved Quality gate approved the PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw][test audit] vscode_parser: _BoundedFileSummaryCache has no unit tests

2 participants