@@ -306,49 +306,35 @@ impl Drop for ServerPanicHookHandler {
306306mod tests {
307307 use anyhow:: Result ;
308308 use lsp_types:: notification:: PublishDiagnostics ;
309- use regex:: escape;
310309 use ruff_db:: system:: SystemPath ;
311- use tempfile:: TempDir ;
312310
313311 use crate :: session:: ClientOptions ;
314312 use crate :: test:: TestServerBuilder ;
315313
316- fn tempdir_filter ( temp_dir : & TempDir ) -> String {
317- format ! ( r"{}\\?/?" , escape( temp_dir. path( ) . to_str( ) . unwrap( ) ) )
318- }
319-
320314 #[ test]
321315 fn initialization ( ) -> Result < ( ) > {
322- let server = TestServerBuilder :: new ( )
316+ let server = TestServerBuilder :: new ( ) ?
323317 . build ( ) ?
324318 . wait_until_workspaces_are_initialized ( ) ?;
325319
326320 let initialization_result = server. initialization_result ( ) . unwrap ( ) ;
327321
328- insta:: with_settings!( {
329- filters => vec![ ( tempdir_filter( server. temp_dir( ) ) . as_str( ) , "[TMP]/" ) ]
330- } , {
331322 insta:: assert_json_snapshot!( "initialization" , initialization_result) ;
332- } ) ;
333323
334324 Ok ( ( ) )
335325 }
336326
337327 #[ test]
338328 fn initialization_with_workspace ( ) -> Result < ( ) > {
339329 let workspace_root = SystemPath :: new ( "foo" ) ;
340- let server = TestServerBuilder :: new ( )
330+ let server = TestServerBuilder :: new ( ) ?
341331 . with_workspace ( workspace_root, ClientOptions :: default ( ) ) ?
342332 . build ( ) ?
343333 . wait_until_workspaces_are_initialized ( ) ?;
344334
345335 let initialization_result = server. initialization_result ( ) . unwrap ( ) ;
346336
347- insta:: with_settings!( {
348- filters => vec![ ( tempdir_filter( server. temp_dir( ) ) . as_str( ) , "[TMP]/" ) ]
349- } , {
350337 insta:: assert_json_snapshot!( "initialization_with_workspace" , initialization_result) ;
351- } ) ;
352338
353339 Ok ( ( ) )
354340 }
@@ -362,21 +348,17 @@ def foo() -> str:
362348 return 42
363349" ;
364350
365- let mut server = TestServerBuilder :: new ( )
351+ let mut server = TestServerBuilder :: new ( ) ?
366352 . with_workspace ( workspace_root, ClientOptions :: default ( ) ) ?
367- . write_file ( foo, foo_content) ?
353+ . with_file ( foo, foo_content) ?
368354 . enable_pull_diagnostics ( false )
369355 . build ( ) ?
370356 . wait_until_workspaces_are_initialized ( ) ?;
371357
372358 server. open_text_document ( foo, & foo_content) ;
373359 let diagnostics = server. await_notification :: < PublishDiagnostics > ( ) ?;
374360
375- insta:: with_settings!( {
376- filters => vec![ ( tempdir_filter( server. temp_dir( ) ) . as_str( ) , "[TMP]/" ) ]
377- } , {
378- insta:: assert_debug_snapshot!( diagnostics) ;
379- } ) ;
361+ insta:: assert_debug_snapshot!( diagnostics) ;
380362
381363 Ok ( ( ) )
382364 }
@@ -390,21 +372,17 @@ def foo() -> str:
390372 return 42
391373" ;
392374
393- let mut server = TestServerBuilder :: new ( )
394- . write_file ( foo, foo_content) ?
375+ let mut server = TestServerBuilder :: new ( ) ?
395376 . with_workspace ( workspace_root, ClientOptions :: default ( ) ) ?
377+ . with_file ( foo, foo_content) ?
396378 . enable_pull_diagnostics ( true )
397379 . build ( ) ?
398380 . wait_until_workspaces_are_initialized ( ) ?;
399381
400382 server. open_text_document ( foo, & foo_content) ;
401383 let diagnostics = server. document_diagnostic_request ( foo) ?;
402384
403- insta:: with_settings!( {
404- filters => vec![ ( tempdir_filter( server. temp_dir( ) ) . as_str( ) , "[TMP]/" ) ]
405- } , {
406385 insta:: assert_debug_snapshot!( diagnostics) ;
407- } ) ;
408386
409387 Ok ( ( ) )
410388 }
0 commit comments