Skip to content

refactor(tests): replace shared corpus with per-feature snapshot dirs - #534

Merged
16bit-ykiko merged 1 commit into
mainfrom
refactor/remove-shared-corpus
Jul 19, 2026
Merged

16bit-ykiko merged 1 commit into
mainfrom
refactor/remove-shared-corpus

Conversation

@16bit-ykiko

Copy link
Copy Markdown
Member

Why

The shared snapshot corpus (tests/corpus/) ran every corpus file through five unrelated feature suites (folding_range, semantic_tokens, document_symbol, inlay_hint, tu_index). Language constructs do not map 1:1 across features, so each corpus file generated noise snapshots for features that do not care about it, making snapshot review scale badly.

What

  • Remove the shared corpus mechanism: tests/corpus/, the --corpus-dir CLI option, the corpus_dir global, and its references in pixi.toml and the docs.
  • Re-point each of the five snapshot glob tests at its own curated directory tests/data/<feature>/, following the existing tests/data/hover/ pattern. The dump/transform logic is kept unchanged for reuse in the upcoming per-feature snapshot migration.
  • Seed each directory with a feature-tailored basic.cpp plus a DisableFormat: true .clang-format (fixture layout is part of the tested input; formatting would invalidate line/column-sensitive snapshots).
  • Regenerate snapshots; each seed produces richer output for its feature than the old shared corpus file did.

Tests

  • Unit: 1026 passed (12 pre-existing skips)
  • Integration: 300 passed
  • Smoke: 3/3 passed

@coderabbitai

coderabbitai Bot commented Jul 19, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The unit-test CLI now uses --test-dir instead of --corpus-dir. Feature snapshot tests read dedicated seed fixtures, with corresponding expected snapshots added and fixture formatting disabled.

Changes

Snapshot corpus migration

Layer / File(s) Summary
Test directory CLI plumbing
tests/unit/unit_tests.cc, tests/unit/test/platform.h, pixi.toml, docs/*/dev/test-and-debug.md
Renames the test path option to --test-dir, removes --corpus-dir, and updates the documented command.
Per-feature snapshot harnesses
tests/unit/feature/*_tests.cpp, tests/unit/index/tu_index_tests.cpp
Snapshot tests glob dedicated directories for document symbols, folding ranges, inlay hints, semantic tokens, and TU indexing.
Seed fixtures and expected snapshots
tests/data/*, tests/snapshots/*/snapshot/basic.cpp.snap.yml
Adds format-stable C++ seed files and matching expected YAML snapshots for each feature.

Estimated code review effort: 2 (Simple) | ~15 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: replacing the shared corpus with per-feature snapshot directories.
Description check ✅ Passed The description matches the changeset and accurately explains the refactor, fixture additions, and snapshot regeneration.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/remove-shared-corpus

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unit/feature/folding_range_tests.cpp`:
- Around line 436-439: The test snapshot paths can become absolute root paths
when clice::testing::test_dir is empty. Update the ASSERT_SNAPSHOT_GLOB path
composition in tests/unit/feature/folding_range_tests.cpp lines 436-439 and
tests/unit/feature/inlay_hint_tests.cpp lines 1539-1542 to join test_dir with
the feature directory safely, preserving a relative “folding_range” or
“inlay_hint” path when the base is empty.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: fc7891d6-2d88-4d4c-9798-7237486a8125

📥 Commits

Reviewing files that changed from the base of the PR and between d9c8083 and 7e89575.

📒 Files selected for processing (31)
  • docs/en/dev/test-and-debug.md
  • docs/zh/dev/test-and-debug.md
  • pixi.toml
  • tests/corpus/statements/if/basic_if.cpp
  • tests/data/document_symbol/.clang-format
  • tests/data/document_symbol/basic.cpp
  • tests/data/folding_range/.clang-format
  • tests/data/folding_range/basic.cpp
  • tests/data/inlay_hint/.clang-format
  • tests/data/inlay_hint/basic.cpp
  • tests/data/semantic_tokens/.clang-format
  • tests/data/semantic_tokens/basic.cpp
  • tests/data/tu_index/.clang-format
  • tests/data/tu_index/basic.cpp
  • tests/snapshots/document_symbol/snapshot/basic.cpp.snap.yml
  • tests/snapshots/document_symbol/snapshot/statements/if/basic_if.cpp.snap.yml
  • tests/snapshots/folding_range/snapshot/basic.cpp.snap.yml
  • tests/snapshots/folding_range/snapshot/statements/if/basic_if.cpp.snap.yml
  • tests/snapshots/inlay_hint/snapshot/basic.cpp.snap.yml
  • tests/snapshots/inlay_hint/snapshot/statements/if/basic_if.cpp.snap.yml
  • tests/snapshots/semantic_tokens/snapshot/basic.cpp.snap.yml
  • tests/snapshots/semantic_tokens/snapshot/statements/if/basic_if.cpp.snap.yml
  • tests/snapshots/tu_index/snapshot/basic.cpp.snap.yml
  • tests/snapshots/tu_index/snapshot/statements/if/basic_if.cpp.snap.yml
  • tests/unit/feature/document_symbol_tests.cpp
  • tests/unit/feature/folding_range_tests.cpp
  • tests/unit/feature/inlay_hint_tests.cpp
  • tests/unit/feature/semantic_tokens_tests.cpp
  • tests/unit/index/tu_index_tests.cpp
  • tests/unit/test/platform.h
  • tests/unit/unit_tests.cc
💤 Files with no reviewable changes (10)
  • tests/snapshots/folding_range/snapshot/statements/if/basic_if.cpp.snap.yml
  • tests/snapshots/document_symbol/snapshot/statements/if/basic_if.cpp.snap.yml
  • tests/snapshots/tu_index/snapshot/statements/if/basic_if.cpp.snap.yml
  • tests/corpus/statements/if/basic_if.cpp
  • tests/snapshots/inlay_hint/snapshot/statements/if/basic_if.cpp.snap.yml
  • tests/unit/test/platform.h
  • docs/en/dev/test-and-debug.md
  • tests/unit/unit_tests.cc
  • tests/snapshots/semantic_tokens/snapshot/statements/if/basic_if.cpp.snap.yml
  • docs/zh/dev/test-and-debug.md

Comment thread tests/unit/feature/folding_range_tests.cpp
@16bit-ykiko
16bit-ykiko merged commit 5526782 into main Jul 19, 2026
30 checks passed
@16bit-ykiko
16bit-ykiko deleted the refactor/remove-shared-corpus branch July 19, 2026 14:15
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