@@ -702,7 +702,8 @@ pub fn get_connection_id_raw(app_state: &WebAppState) -> u32 {
702702#[ cfg( test) ]
703703mod tests {
704704 use std:: {
705- fs,
705+ backtrace:: Backtrace ,
706+ env, fs,
706707 path:: { Path , PathBuf } ,
707708 str:: FromStr ,
708709 time:: Duration ,
@@ -779,7 +780,10 @@ mod tests {
779780 println!( "{} - {:?}" , m. id, m. message) ;
780781 m
781782 }
782- _ = sleep( Duration :: from_secs( 3 ) ) => panic!( "Timeout waiting for message" )
783+ _ = sleep( Duration :: from_secs( 3 ) ) => {
784+ // The backtrace shows what message the code was waiting for; otherwise, it's an unhelpful error message.
785+ panic!( "Timeout waiting for message:\n {}" , Backtrace :: force_capture( ) ) ;
786+ }
783787 }
784788 }
785789
@@ -860,7 +864,8 @@ mod tests {
860864 false ,
861865 false ,
862866 ) ;
863- let codechat_for_web = cast ! ( cast!( translation_results, Ok ) , TranslationResults :: CodeChat ) ;
867+ let tr = cast ! ( translation_results, Ok ) ;
868+ let codechat_for_web = cast ! ( tr, TranslationResults :: CodeChat ) ;
864869 assert_eq ! ( umc. contents, Some ( codechat_for_web) ) ;
865870
866871 // Report any errors produced when removing the temporary directory.
@@ -987,7 +992,12 @@ mod tests {
987992 // Check that it produces an error.
988993 let ( id, err_msg) = get_message_as ! ( to_client_rx, EditorMessageContents :: Result ) ;
989994 assert_eq ! ( id, INITIAL_CLIENT_MESSAGE_ID + 4.0 * MESSAGE_ID_INCREMENT ) ;
990- cast ! ( cast!( err_msg, Err ) , ResultErrTypes :: WrongFileUpdate , _a, _b) ;
995+ cast ! (
996+ err_msg. as_ref( ) . unwrap_err( ) ,
997+ ResultErrTypes :: WrongFileUpdate ,
998+ _a,
999+ _b
1000+ ) ;
9911001
9921002 // 6. Send an update message with unknown source language.
9931003 //
@@ -1020,7 +1030,10 @@ mod tests {
10201030 msg_id,
10211031 INITIAL_CLIENT_MESSAGE_ID + 5.0 * MESSAGE_ID_INCREMENT
10221032 ) ;
1023- cast ! ( cast!( msg, Err ) , ResultErrTypes :: CannotTranslateCodeChat ) ;
1033+ cast ! (
1034+ msg. as_ref( ) . unwrap_err( ) ,
1035+ ResultErrTypes :: CannotTranslateCodeChat
1036+ ) ;
10241037
10251038 // 7. Send a valid message.
10261039 //
@@ -1064,7 +1077,15 @@ mod tests {
10641077 s. push_str ( "123" ) ;
10651078 fs:: write ( & file_path, s) . unwrap ( ) ;
10661079 // Wait for the filewatcher to debounce this file write.
1067- sleep ( Duration :: from_secs ( 3 ) ) . await ;
1080+ sleep ( Duration :: from_secs (
1081+ // Mac in CI seems to need a long delay here.
1082+ if cfg ! ( target_os = "macos" ) && env:: var ( "CI" ) == Ok ( "true" . to_string ( ) ) {
1083+ 5
1084+ } else {
1085+ 2
1086+ } ,
1087+ ) )
1088+ . await ;
10681089 // The version is random; don't check it with a fixed value.
10691090 let msg = get_message_as ! ( to_client_rx, EditorMessageContents :: Update ) ;
10701091 assert_eq ! (
0 commit comments