From d17de284da5683840e8a6e35559ab86dce9c3831 Mon Sep 17 00:00:00 2001 From: BFlat Date: Fri, 30 Oct 2026 15:53:33 +0700 Subject: [PATCH] Tests: read the docs' examples whatever the checkout's line endings (#1645) inspect_fields::compact_examples_run_verbatim_from_the_docs split docs/mcp.md and docs/control-protocol.md on text ending in a newline, so on a Windows checkout with core.autocrlf (CRLF docs) it panicked and cargo xtask ci failed locally. The test now reads both with LF line ends. Found while gating on Windows. --- crates/mcp/tests/it/inspect_fields.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/mcp/tests/it/inspect_fields.rs b/crates/mcp/tests/it/inspect_fields.rs index 19119aeb..930ba3c7 100644 --- a/crates/mcp/tests/it/inspect_fields.rs +++ b/crates/mcp/tests/it/inspect_fields.rs @@ -154,6 +154,11 @@ fn compact_children_keep_window_markers_and_page_in_order() { assert_eq!(&seen, expected); } +/// `text` with Unix line ends: a Windows checkout with `core.autocrlf` has the docs with CRLF. +fn lf(text: &str) -> String { + text.replace("\r\n", "\n") +} + fn json_example(section: &str) -> &str { section.split("```json\n").nth(1).unwrap().split("```").next().unwrap() } @@ -164,7 +169,7 @@ fn compact_examples_run_verbatim_from_the_docs() { for _ in 0..2 { c.create(json!({"type": "rectangle"})); } - let docs = include_str!("../../../../docs/mcp.md"); + let docs = lf(include_str!("../../../../docs/mcp.md")); let section = docs.split("### Compact layer trees\n").nth(1).unwrap(); for line in json_example(section).lines() { let reply: Value = serde_json::from_str(&c.server.handle_line(line).unwrap()).unwrap(); @@ -174,7 +179,7 @@ fn compact_examples_run_verbatim_from_the_docs() { for _ in 0..2 { h.call("engine.execute", json!({"command": "node.create", "params": {"type": "rectangle"}})).unwrap(); } - let docs = include_str!("../../../../docs/control-protocol.md"); + let docs = lf(include_str!("../../../../docs/control-protocol.md")); let section = docs.split("### `node.get ").nth(1).unwrap(); for line in json_example(section).lines() { let request: Value = serde_json::from_str(line).unwrap();