From eefe6cc9c80f06472cd3ace9b8accbc686e4a14a Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Sat, 5 Dec 2026 22:29:19 +0800 Subject: [PATCH] test(lsp): compare created files without their line separator, everywhere (#8238) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two more tests (ide-lsp gopls_interactive_command…, ide-workspace a_server_edit_versions_files_the_editor_never_opened) read a file a server edit created and expected LF; on Windows a created file takes CRLF. They fold CRLF to LF like #8233. --- crates/ide-lsp/tests/integration/mock_server.rs | 6 +++++- crates/ide-workspace/tests/integration/workspace_edits.rs | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/ide-lsp/tests/integration/mock_server.rs b/crates/ide-lsp/tests/integration/mock_server.rs index 1de6176411..39476e8aa0 100644 --- a/crates/ide-lsp/tests/integration/mock_server.rs +++ b/crates/ide-lsp/tests/integration/mock_server.rs @@ -7832,7 +7832,11 @@ async fn gopls_interactive_command_validates_before_execution_and_applies_edits( .await .unwrap(); assert_eq!(created, vec![new_file.clone()]); - assert_eq!(std::fs::read_to_string(&new_file).unwrap(), "package probe_test\n\nimport \"testing\"\n"); + // A created file takes the system line separator (CRLF on Windows). + assert_eq!( + std::fs::read_to_string(&new_file).unwrap().replace("\r\n", "\n"), + "package probe_test\n\nimport \"testing\"\n" + ); } /// bash-language-server formats a whole file with `Position.create(Number.MAX_VALUE, diff --git a/crates/ide-workspace/tests/integration/workspace_edits.rs b/crates/ide-workspace/tests/integration/workspace_edits.rs index 503a3c6ffc..d493f92b96 100644 --- a/crates/ide-workspace/tests/integration/workspace_edits.rs +++ b/crates/ide-workspace/tests/integration/workspace_edits.rs @@ -363,7 +363,8 @@ fn a_server_edit_versions_files_the_editor_never_opened() { assert!(!created.exists()); docs.apply_server_edit(extract(typed)).unwrap(); assert_eq!(docs.snapshot(info.id).unwrap().text, "new\nmore\n"); - assert_eq!(std::fs::read_to_string(&created).unwrap(), "moved\n"); + // A created file takes the system line separator (CRLF on Windows). + assert_eq!(std::fs::read_to_string(&created).unwrap().replace("\r\n", "\n"), "moved\n"); } #[test]