@@ -327,11 +327,11 @@ fn test_crash_tracking_app(crash_type: &str) {
327327
328328 match crash_type_owned. as_str ( ) {
329329 "panic" => {
330- let expected_message = "program panicked" ;
331- assert_eq ! (
332- error [ " message" ] . as_str ( ) . unwrap ( ) ,
333- expected_message ,
334- "Expected panic message for panic crash type"
330+ let message = error [ "message" ] . as_str ( ) . unwrap ( ) ;
331+ assert ! (
332+ message. contains ( "Process panicked with message" ) && message . contains ( "program panicked" ) ,
333+ "Expected panic message to contain 'Process panicked with message' and 'program panicked', got: {}" ,
334+ message
335335 ) ;
336336 }
337337 "segfault" => {
@@ -360,6 +360,31 @@ fn test_crash_tracking_app(crash_type: &str) {
360360#[ cfg_attr( miri, ignore) ]
361361#[ cfg( not( target_os = "macos" ) ) ] // Same restriction as other panic tests
362362fn test_crash_tracking_bin_panic_hook_after_fork ( ) {
363+ test_panic_hook_mode ( "panic_hook_after_fork" , "child panicked after fork" ) ;
364+ }
365+
366+ #[ test]
367+ #[ cfg_attr( miri, ignore) ]
368+ #[ cfg( not( target_os = "macos" ) ) ] // Same restriction as other panic tests
369+ fn test_crash_tracking_bin_panic_hook_string ( ) {
370+ test_panic_hook_mode (
371+ "panic_hook_string" ,
372+ "Process panicked with message: Panic with value: 42" ,
373+ ) ;
374+ }
375+
376+ #[ test]
377+ #[ cfg_attr( miri, ignore) ]
378+ #[ cfg( not( target_os = "macos" ) ) ] // Same restriction as other panic tests
379+ fn test_crash_tracking_bin_panic_hook_unknown_type ( ) {
380+ test_panic_hook_mode (
381+ "panic_hook_unknown_type" ,
382+ "Process panicked with unknown type" ,
383+ ) ;
384+ }
385+
386+ /// Helper function to run panic hook tests with different payload types
387+ fn test_panic_hook_mode ( mode : & str , expected_message_substring : & str ) {
363388 use bin_tests:: test_runner:: run_custom_crash_test;
364389
365390 // Set up custom artifacts: receiver + crashtracker_bin_test
@@ -368,24 +393,18 @@ fn test_crash_tracking_bin_panic_hook_after_fork() {
368393
369394 let artifacts_map = build_artifacts ( & [ & crashtracker_receiver, & crashtracker_bin_test] ) . unwrap ( ) ;
370395
371- let validator: ValidatorFn = Box :: new ( |payload, _fixtures| {
396+ let expected_msg = expected_message_substring. to_owned ( ) ;
397+ let validator: ValidatorFn = Box :: new ( move |payload, _fixtures| {
372398 // Verify the panic message is captured
373399 let error = & payload[ "error" ] ;
374400 let message = error[ "message" ] . as_str ( ) . unwrap ( ) ;
375401 assert ! (
376- message. contains( "child panicked after fork" ) ,
377- "Expected panic message to contain 'child panicked after fork', got: {}" ,
402+ message. contains( & expected_msg) ,
403+ "Expected panic message to contain '{}', got: {}" ,
404+ expected_msg,
378405 message
379406 ) ;
380407
381- // TODO change the kind into Panic instead
382- let kind = error[ "kind" ] . as_str ( ) . unwrap ( ) ;
383- assert_eq ! (
384- kind, "UnixSignal" ,
385- "Expected error kind to be UnixSignal, got: {}" ,
386- kind
387- ) ;
388-
389408 Ok ( ( ) )
390409 } ) ;
391410
@@ -395,8 +414,8 @@ fn test_crash_tracking_bin_panic_hook_after_fork() {
395414 cmd. arg ( format ! ( "file://{}" , fixtures. crash_profile_path. display( ) ) )
396415 . arg ( & artifacts_map[ & crashtracker_receiver] )
397416 . arg ( & fixtures. output_dir )
398- . arg ( "panic_hook_after_fork" ) // mode
399- . arg ( "donothing" ) ; // crash method (not used in this mode )
417+ . arg ( mode)
418+ . arg ( "donothing" ) ; // crash method (not used in panic hook tests )
400419 } ,
401420 validator,
402421 )
0 commit comments