From 452d89703296d883a12def40a09565b0f6a7e0ff Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sat, 5 Dec 2026 21:33:47 +0800 Subject: [PATCH] test(lsp): compare created files without their line separator (#8233) a_server_edit_may_version_files_the_editor_never_opened expected LF in files a server edit created, but created files take the system line separator, so it failed on Windows. The test now folds CRLF to LF before comparing. --- crates/ide-host/tests/integration/workspace_edits.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/ide-host/tests/integration/workspace_edits.rs b/crates/ide-host/tests/integration/workspace_edits.rs index 810a0194b8..83fe23dc9e 100644 --- a/crates/ide-host/tests/integration/workspace_edits.rs +++ b/crates/ide-host/tests/integration/workspace_edits.rs @@ -342,11 +342,10 @@ async fn a_server_edit_may_version_files_the_editor_never_opened() { ops::lsp::lsp_execute_command(&host, "main", info.id, command) }; + // A created file takes the system line separator (CRLF on Windows). + let read = |name: &str| std::fs::read_to_string(root.join(name)).unwrap().replace("\r\n", "\n"); run("gopls.add_test", json!({})).await.unwrap(); - assert_eq!( - std::fs::read_to_string(root.join("add_test.go")).unwrap(), - "package x_test\n\nimport \"testing\"\n\nfunc TestAdd(t *testing.T) {}\n" - ); + assert_eq!(read("add_test.go"), "package x_test\n\nimport \"testing\"\n\nfunc TestAdd(t *testing.T) {}\n"); // The open file must still be at the version the server names: an edit made before the // user typed is refused. @@ -371,6 +370,6 @@ async fn a_server_edit_may_version_files_the_editor_never_opened() { ops::doc::doc_snapshot(&host, "main", info.id).await.unwrap().text, "package x\n\n// Add returns the sum.\nfunc Add(a, b int) int { return a + b }\n\n// more\n" ); - assert_eq!(std::fs::read_to_string(root.join("two.go")).unwrap(), "package x\n\nfunc Two() int { return 2 }\n"); + assert_eq!(read("two.go"), "package x\n\nfunc Two() int { return 2 }\n"); accept.abort(); }