Skip to content

chore: Add tests and fix rename deadlock#141

Merged
coder3101 merged 1 commit into
mainfrom
add-tests
Jul 11, 2026
Merged

chore: Add tests and fix rename deadlock#141
coder3101 merged 1 commit into
mainfrom
add-tests

Conversation

@coder3101

Copy link
Copy Markdown
Owner

Summary

Adds 43 new tests across 4 modules and fixes a deadlock bug discovered during testing.

Changes

src/protoc.rs — 7 tests for parse_protoc_output: single error, multiple errors, empty output, malformed line, partial format, non-numeric line/col, message with colons.

src/nodekind.rs — 14 tests covering all NodeKind predicates against real tree-sitter parse trees (is_identifier, is_message_name, is_enum_name, is_field_name, is_rpc_name, is_package_name, is_import_path, is_error, is_message, is_userdefined, is_renameable, is_field_decl_parent, is_actionable, to_symbolkind, as_str).

src/state.rs — 16 tests for get_content, get_tree, get_trees, get_trees_for_package, completion_items, find_workspace_symbols, delete_file, rename_file, upsert_content, parse_all_from_workspace, upsert_file.

src/utils.rs — 6 new tests for ts_to_lsp_position, lsp_to_ts_point, round-trip, zero/large values, and additional split_identifier_package edge cases.

Bug fix

Fixed a deadlock in rename_file() where the same RwLock write guard was acquired twice without dropping the first one (the if let Some(v) = self.x.write().remove(...) { self.x.write().insert(...) } pattern).

- protoc.rs: 7 tests for parse_protoc_output (single/multiple errors,
  empty/malformed input, partial format, non-numeric, colons in message)
- nodekind.rs: 14 tests covering all NodeKind predicates against real
  tree-sitter parse trees
- state.rs: 16 tests for get_content, get_tree, get_trees,
  get_trees_for_package, completion_items, find_workspace_symbols,
  delete_file, rename_file, upsert_content, parse_all_from_workspace,
  upsert_file
- utils.rs: 6 new tests for ts_to_lsp_position, lsp_to_ts_point,
  round-trip, zero/large values, and additional split_identifier_package
  edge cases

Also fixes a deadlock in rename_file() where the same RwLock write guard
was acquired twice without dropping the first one.

Signed-off-by: Ashar <ashar786khan@gmail.com>
@coder3101 coder3101 changed the title Add tests for protoc, nodekind, state, and utils modules chore: Add tests for protoc, nodekind, state, and utils modules Jul 11, 2026
@coder3101 coder3101 changed the title chore: Add tests for protoc, nodekind, state, and utils modules chore: Add tests and fix rename deadlock Jul 11, 2026
@coder3101 coder3101 merged commit 2ec585c into main Jul 11, 2026
6 checks passed
@coder3101 coder3101 deleted the add-tests branch July 11, 2026 18:24
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