Skip to content

test(lsp): snapshot the rename tests - #2264

Merged
Peefy merged 2 commits into
mainfrom
cursor/lsp-rename-test-snapshots-9ad2
Nov 20, 2026
Merged

Peefy merged 2 commits into
mainfrom
cursor/lsp-rename-test-snapshots-9ad2

Conversation

@Peefy

@Peefy Peefy commented Nov 17, 2026

Copy link
Copy Markdown
Contributor

Fixes #1374.

Summary

rename was the last open item on the LSP unit-test checklist. Those tests asserted structural results of internal helpers (package_path_to_file_path, select_symbol, exact TextEdits) and shared one in-memory VFS. This PR splits them into per-test fixtures and insta snapshots, in the same style as goto-def, hover, find-refs, formatting, semantic tokens, inlay hints, signature help, and completion.

  • Each former assertion is its own test, invoked through package_path_test_snapshot!, select_symbol_test_snapshot!, rename_symbol_test_snapshot!, rename_on_code_test_snapshot!, or rename_on_file_test_snapshot!.
  • Fixtures live under src/test_data/rename/<case>/. The e2e workspace in src/test_data/rename_test/ is left in place. The mutable rename_on_file copy is gone; the on-file test copies its fixture into a temp directory and snapshots the written sources.
  • Snapshots record relative paths, symbol names and ranges, text-edit ranges, and the renamed source. The recorded ranges and source match the old asserts.
  • apply_rename_changes snapshots the rewritten file instead of assert_eq!.

Production rename behavior is unchanged. The diff stays in crates/tools/src/LSP tests, fixtures, and snapshots.

The e2e server helpers (Server::open_file, Server::rename, and the rest) were already in place, and the other checklist suites were already converted. This finishes the checklist.

Tests

cargo test --manifest-path crates/tools/src/LSP/Cargo.toml --lib rename — 16 passed (14 snapshot tests plus the existing e2e rename_test and rename_debug_test).

Open in Web Open in Cursor 

cursoragent and others added 2 commits November 17, 2026 09:06
Give each rename case its own fixture and an insta snapshot, in the
same style as the other LSP suites. The shared in-memory VFS and the
structural asserts on package paths, symbol selection, and text edits
are gone. Production rename behavior is unchanged.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Peefy <Peefy@users.noreply.github.com>
Virtual fixture paths now always start with `/`, which
`VfsPath::new_virtual_path` requires. Real source-map keys use the
normalized VFS spelling so applying edits can find the file, and the
on-file test canonicalizes its temp directory before renaming.

Signed-off-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: Peefy <Peefy@users.noreply.github.com>
@Peefy
Peefy merged commit 4e4df13 into main Nov 20, 2026
9 checks passed
@Peefy
Peefy deleted the cursor/lsp-rename-test-snapshots-9ad2 branch November 20, 2026 02:03
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.

[Refactor] refactor lsp tests

2 participants