@@ -673,9 +673,11 @@ mod test {
673673 use actix_rt:: task:: JoinHandle ;
674674 use assert_fs:: TempDir ;
675675 use assertables:: { assert_ends_with, assert_starts_with} ;
676+ use dunce:: simplified;
676677 use futures_util:: { SinkExt , StreamExt } ;
677678 use lazy_static:: lazy_static;
678679 use minreq;
680+ use path_slash:: PathExt ;
679681 use tokio:: {
680682 io:: { AsyncRead , AsyncWrite } ,
681683 net:: TcpStream ,
@@ -927,14 +929,17 @@ mod test {
927929 let ( temp_dir, test_dir, mut ws_ide, _) = prep_test ! ( connection_id) . await ;
928930 open_client ( & mut ws_ide) . await ;
929931
932+ let file_path = test_dir. join ( "none.py" ) ;
933+ let file_path_str = file_path. to_slash ( ) . unwrap ( ) . to_string ( ) ;
934+
930935 // Do this is a thread, since the request generates a message that
931936 // requires a response in order to complete.
932- let test_dir_thread = test_dir . clone ( ) ;
937+ let file_path_str_thread = file_path_str . clone ( ) ;
933938 let join_handle = thread:: spawn ( move || {
934939 assert_eq ! (
935940 minreq:: get( format!(
936- "http://localhost:8080/vsc/fs/{connection_id}/{}/none.py " ,
937- test_dir_thread . to_str ( ) . unwrap ( )
941+ "http://localhost:8080/vsc/fs/{connection_id}/{}" ,
942+ file_path_str_thread
938943 ) )
939944 . send( )
940945 . unwrap( )
@@ -950,10 +955,7 @@ mod test {
950955 let msg = cast ! ( em. message, EditorMessageContents :: LoadFile ) ;
951956 // Compare these as strings -- we want to ensure the path separator is
952957 // correct for the current platform.
953- assert_eq ! (
954- test_dir. join( "none.py" ) . to_str( ) . unwrap( ) . to_string( ) ,
955- msg. to_string_lossy( )
956- ) ;
958+ assert_eq ! ( file_path. to_string_lossy( ) , msg. to_string_lossy( ) ) ;
957959 assert_eq ! ( em. id, 3.0 ) ;
958960
959961 // Reply to the `LoadFile` message -- the file isn't present.
@@ -984,16 +986,13 @@ mod test {
984986 open_client ( & mut ws_ide) . await ;
985987
986988 // Message ids: IDE - 4->7, Server - 3, Client - 2.
987- let file_path = test_dir
988- . join ( "only-in-ide.py" )
989- . to_str ( )
990- . unwrap ( )
991- . to_string ( ) ;
989+ let file_path = test_dir. join ( "only-in-ide.py" ) ;
990+ let file_path_str = file_path. to_str ( ) . unwrap ( ) . to_string ( ) ;
992991 send_message (
993992 & mut ws_ide,
994993 & EditorMessage {
995994 id : 4.0 ,
996- message : EditorMessageContents :: CurrentFile ( file_path . clone ( ) ) ,
995+ message : EditorMessageContents :: CurrentFile ( file_path_str . clone ( ) ) ,
997996 } ,
998997 )
999998 . await ;
@@ -1026,12 +1025,12 @@ mod test {
10261025 ) ;
10271026
10281027 // The Client should send a GET request for this file.
1029- let test_dir_thread = test_dir . clone ( ) ;
1028+ let file_path_thread = file_path . clone ( ) ;
10301029 let join_handle = thread:: spawn ( move || {
10311030 assert_eq ! (
10321031 minreq:: get( format!(
1033- "http://localhost:8080/vsc/fs/{connection_id}/{}/only-in-ide.py " ,
1034- test_dir_thread . to_str ( ) . unwrap( )
1032+ "http://localhost:8080/vsc/fs/{connection_id}/{}" ,
1033+ file_path_thread . to_slash ( ) . unwrap( )
10351034 ) )
10361035 . send( )
10371036 . unwrap( )
@@ -1072,7 +1071,7 @@ mod test {
10721071 EditorMessage {
10731072 id: 6.0 ,
10741073 message: EditorMessageContents :: Update ( UpdateMessageContents {
1075- file_path,
1074+ file_path: file_path_str . clone ( ) ,
10761075 contents: Some ( CodeChatForWeb {
10771076 metadata: SourceFileMetadata {
10781077 mode: "python" . to_string( ) ,
@@ -1128,28 +1127,22 @@ mod test {
11281127 // translated.
11291128 //
11301129 // Message ids: IDE - 4, Server - 3, Client - 2->5.
1131- let file_path = test_dir. join ( "test.py" ) . to_string_lossy ( ) . to_string ( ) ;
1130+ let file_path = test_dir. join ( "test.py" ) ;
1131+ let file_path_str = file_path. to_str ( ) . unwrap ( ) . to_string ( ) ;
11321132 send_message (
11331133 & mut ws_client,
11341134 & EditorMessage {
11351135 id : 2.0 ,
11361136 message : EditorMessageContents :: CurrentFile ( format ! (
11371137 "http://localhost:8080/vsc/fs/{connection_id}/{}" ,
1138- & file_path
1138+ & file_path. to_slash ( ) . unwrap ( )
11391139 ) ) ,
11401140 } ,
11411141 )
11421142 . await ;
11431143 let em = read_message ( & mut ws_ide) . await ;
11441144 let cf = cast ! ( em. message, EditorMessageContents :: CurrentFile ) ;
1145- assert_eq ! (
1146- path:: absolute( Path :: new( & cf) ) . unwrap( ) ,
1147- path:: absolute( Path :: new( & format!(
1148- "{}/test.py" ,
1149- test_dir. to_str( ) . unwrap( )
1150- ) ) )
1151- . unwrap( )
1152- ) ;
1145+ assert_eq ! ( path:: absolute( Path :: new( & cf) ) . unwrap( ) , file_path) ;
11531146 assert_eq ! ( em. id, 2.0 ) ;
11541147
11551148 send_message (
@@ -1176,7 +1169,7 @@ mod test {
11761169 & EditorMessage {
11771170 id : 4.0 ,
11781171 message : EditorMessageContents :: Update ( UpdateMessageContents {
1179- file_path : file_path . clone ( ) ,
1172+ file_path : file_path_str . clone ( ) ,
11801173 contents : Some ( CodeChatForWeb {
11811174 metadata : SourceFileMetadata {
11821175 mode : "python" . to_string ( ) ,
@@ -1197,7 +1190,7 @@ mod test {
11971190 EditorMessage {
11981191 id: 4.0 ,
11991192 message: EditorMessageContents :: Update ( UpdateMessageContents {
1200- file_path,
1193+ file_path: file_path_str . clone ( ) ,
12011194 contents: Some ( CodeChatForWeb {
12021195 metadata: SourceFileMetadata {
12031196 mode: "python" . to_string( ) ,
@@ -1325,29 +1318,23 @@ mod test {
13251318 open_client ( & mut ws_ide) . await ;
13261319
13271320 // Message ids: IDE - 4, Server - 3, Client - 2->5.
1328- let file_path = test_dir. join ( "test.py" ) . to_str ( ) . unwrap ( ) . to_string ( ) ;
1321+ let file_path_temp = fs:: canonicalize ( test_dir. join ( "test.py" ) ) . unwrap ( ) ;
1322+ let file_path = simplified ( & file_path_temp) ;
13291323 send_message (
13301324 & mut ws_client,
13311325 & EditorMessage {
13321326 id : 2.0 ,
13331327 message : EditorMessageContents :: CurrentFile ( format ! (
13341328 "http://localhost:8080/vsc/fs/{connection_id}/{}" ,
1335- & file_path
1329+ & file_path. to_slash ( ) . unwrap ( )
13361330 ) ) ,
13371331 } ,
13381332 )
13391333 . await ;
13401334
13411335 let em = read_message ( & mut ws_ide) . await ;
13421336 let cf = cast ! ( em. message, EditorMessageContents :: CurrentFile ) ;
1343- assert_eq ! (
1344- fs:: canonicalize( Path :: new( & cf) ) . unwrap( ) ,
1345- fs:: canonicalize( Path :: new( & format!(
1346- "{}/test.py" ,
1347- test_dir. to_str( ) . unwrap( )
1348- ) ) )
1349- . unwrap( )
1350- ) ;
1337+ assert_eq ! ( cf, file_path. to_str( ) . unwrap( ) . to_string( ) ) ;
13511338 assert_eq ! ( em. id, 2.0 ) ;
13521339
13531340 send_message (
@@ -1372,7 +1359,7 @@ mod test {
13721359 assert_eq ! (
13731360 minreq:: get( format!(
13741361 "http://localhost:8080/vsc/fs/{connection_id}/{}/{}" ,
1375- test_dir_thread. to_str ( ) . unwrap( ) ,
1362+ test_dir_thread. to_slash ( ) . unwrap( ) ,
13761363 // On Windows, send incorrect case for this file; the server should correct it.
13771364 if cfg!( windows) { "Test.py" } else { "test.py" }
13781365 ) )
@@ -1388,10 +1375,7 @@ mod test {
13881375 // Message ids: IDE - 4, Server - 3->6, Client - 5.
13891376 let em = read_message ( & mut ws_ide) . await ;
13901377 let msg = cast ! ( em. message, EditorMessageContents :: LoadFile ) ;
1391- assert_eq ! (
1392- fs:: canonicalize( & msg) . unwrap( ) ,
1393- fs:: canonicalize( test_dir. join( "test.py" ) ) . unwrap( )
1394- ) ;
1378+ assert_eq ! ( fs:: canonicalize( & msg) . unwrap( ) , file_path_temp) ;
13951379 assert_eq ! ( em. id, 3.0 ) ;
13961380
13971381 // Reply to the `LoadFile` message: the IDE doesn't have the file.
@@ -1413,7 +1397,7 @@ mod test {
14131397 EditorMessage {
14141398 id: 6.0 ,
14151399 message: EditorMessageContents :: Update ( UpdateMessageContents {
1416- file_path,
1400+ file_path: file_path . to_str ( ) . unwrap ( ) . to_string ( ) ,
14171401 contents: Some ( CodeChatForWeb {
14181402 metadata: SourceFileMetadata {
14191403 mode: "python" . to_string( ) ,
0 commit comments