Skip to content

Commit 2fe95ff

Browse files
committed
test(ra_e2e): add e2e coverage for 4 LSP 3.17 tools and MCP resources
Add 7 sub-cases to ra_e2e_suite: - sc_get_signature_help, sc_go_to_implementation, sc_go_to_type_definition, sc_get_inlay_hints — cover the 4 tools added in #124 that had no e2e coverage against real rust-analyzer - sc_list_resources, sc_read_resource, sc_subscribe_unsubscribe_resource — cover the MCP resources path (list/read/subscribe/unsubscribe) end-to-end Add list_resources, read_resource, subscribe_resource, unsubscribe_resource to McpClient test helper. Add lib_rs_uri() helper that derives the lsp-diagnostics:// URI from the live resources/list response to avoid path-encoding drift on macOS canonicalised paths. Append lsp317_target() to the rust_workspace fixture as a stable anchor for the new sub-cases (append-only, no existing anchors disturbed). Closes #129, closes #130
1 parent 852b1f3 commit 2fe95ff

4 files changed

Lines changed: 449 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2525

2626
- **LSP server requests** — Handle server-to-client requests such as `client/registerCapability`, fixing tsgo timeouts.
2727
- **Integration tests** — Add `[workspace]` table to `tests/fixtures/rust_workspace/Cargo.toml` so cargo treats the fixture as a standalone workspace; fixes 8 rust-analyzer integration tests that failed with "Failed to load workspaces." (#118)
28+
- **e2e coverage** — Add ra_e2e sub-cases for `get_signature_help`, `go_to_implementation`, `go_to_type_definition`, `get_inlay_hints` (4 LSP 3.17 tools from #124 had no coverage); add `list_resources`, `read_resource`, `subscribe_resource`, `unsubscribe_resource` to `McpClient` and ra_e2e_suite (MCP resources path was entirely untested) (#129, #130)
2829

2930
## [0.3.6] - 2026-04-21
3031

crates/mcpls-core/tests/e2e/mcp_client.rs

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,70 @@ impl McpClient {
190190
self.send_request(&request)
191191
}
192192

193+
/// List MCP resources (`resources/list`).
194+
///
195+
/// # Errors
196+
///
197+
/// Returns an error if the request cannot be sent or the server returns an error.
198+
#[allow(dead_code)]
199+
pub fn list_resources(&mut self) -> Result<Value> {
200+
let request = json!({
201+
"jsonrpc": "2.0",
202+
"id": self.next_id(),
203+
"method": "resources/list",
204+
"params": {}
205+
});
206+
self.send_request(&request)
207+
}
208+
209+
/// Read an MCP resource by URI (`resources/read`).
210+
///
211+
/// # Errors
212+
///
213+
/// Returns an error if the request cannot be sent or the server returns an error.
214+
#[allow(dead_code)]
215+
pub fn read_resource(&mut self, uri: &str) -> Result<Value> {
216+
let request = json!({
217+
"jsonrpc": "2.0",
218+
"id": self.next_id(),
219+
"method": "resources/read",
220+
"params": { "uri": uri }
221+
});
222+
self.send_request(&request)
223+
}
224+
225+
/// Subscribe to a resource (`resources/subscribe`).
226+
///
227+
/// # Errors
228+
///
229+
/// Returns an error if the request cannot be sent or the server returns an error.
230+
#[allow(dead_code)]
231+
pub fn subscribe_resource(&mut self, uri: &str) -> Result<Value> {
232+
let request = json!({
233+
"jsonrpc": "2.0",
234+
"id": self.next_id(),
235+
"method": "resources/subscribe",
236+
"params": { "uri": uri }
237+
});
238+
self.send_request(&request)
239+
}
240+
241+
/// Unsubscribe from a resource (`resources/unsubscribe`).
242+
///
243+
/// # Errors
244+
///
245+
/// Returns an error if the request cannot be sent or the server returns an error.
246+
#[allow(dead_code)]
247+
pub fn unsubscribe_resource(&mut self, uri: &str) -> Result<Value> {
248+
let request = json!({
249+
"jsonrpc": "2.0",
250+
"id": self.next_id(),
251+
"method": "resources/unsubscribe",
252+
"params": { "uri": uri }
253+
});
254+
self.send_request(&request)
255+
}
256+
193257
/// Send a raw JSON-RPC request and return the response.
194258
///
195259
/// # Errors

crates/mcpls-core/tests/fixtures/rust_workspace/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,3 +94,11 @@ pub struct CodeActionTarget;
9494
// split to multi-line so RA can offer "implement missing members" inside the block
9595
impl Greet for CodeActionTarget {
9696
}
97+
98+
/// Stable target for LSP 3.17 sub-cases (signature help, type definition, inlay hints).
99+
#[allow(dead_code, clippy::let_underscore_untyped)]
100+
pub fn lsp317_target() {
101+
let p = Point { x: 1.0, y: 2.0 };
102+
let s = add(1, 2);
103+
let _ = (p, s);
104+
}

0 commit comments

Comments
 (0)