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.
Цей коміт міститься в:
l0ng-ai authored and GitHub committed 2026-12-05 21:33:47 +08:00
1 джерело a69ff2499d
коміт 452d897032
1 file changed
+4 -5
+4 -5
Переглянути файл
@@ -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();
}