@@ -476,23 +476,28 @@ impl Replayer for ReplayBuffer {
476476mod tests {
477477 use super :: * ;
478478 use crate :: ValRaw ;
479+ use core:: mem:: MaybeUninit ;
479480 use std:: fs:: File ;
480481 use std:: path:: Path ;
481482 use tempfile:: { NamedTempFile , TempPath } ;
482483
483484 #[ test]
485+ #[ cfg( all( feature = "rr" , feature = "rr-component" ) ) ]
484486 fn rr_buffers ( ) -> Result < ( ) > {
485487 let record_settings = RecordSettings :: default ( ) ;
486488 let tmp = NamedTempFile :: new ( ) ?;
487489 let tmppath = tmp. path ( ) . to_str ( ) . expect ( "Filename should be UTF-8" ) ;
488490
489- let values = vec ! [ ValRaw :: i32 ( 1 ) , ValRaw :: f32 ( 2 ) , ValRaw :: i64 ( 3 ) ] ;
491+ let values = vec ! [ ValRaw :: i32 ( 1 ) , ValRaw :: f32 ( 2 ) , ValRaw :: i64 ( 3 ) ]
492+ . into_iter ( )
493+ . map ( |x| MaybeUninit :: new ( x) )
494+ . collect :: < Vec < _ > > ( ) ;
490495
491496 // Record values
492497 let mut recorder =
493498 RecordBuffer :: new_recorder ( Box :: new ( File :: create ( tmppath) ?) , record_settings) ?;
494- let event = component_wasm :: HostFuncReturnEvent :: new ( values . as_slice ( ) , None ) ;
495- recorder . record_event ( event . clone ( ) ) ?;
499+ recorder
500+ . record_event ( || __component_events :: HostFuncReturnEvent :: new ( values . as_slice ( ) ) ) ?;
496501 recorder. flush ( ) ?;
497502
498503 let tmp = tmp. into_temp_path ( ) ;
@@ -504,9 +509,16 @@ mod tests {
504509 // Assert that replayed values are identical
505510 let mut replayer =
506511 ReplayBuffer :: new_replayer ( Box :: new ( File :: open ( tmppath) ?) , replay_settings) ?;
507- replayer. next_event_and ( |store_event : component_wasm:: HostFuncReturnEvent , _| {
508- // Check replay matches record
509- assert ! ( store_event == event) ;
512+ let mut result_values = values. clone ( ) ;
513+ replayer. next_event_and ( |event : __component_events:: HostFuncReturnEvent | {
514+ event. move_into_slice ( result_values. as_mut_slice ( ) ) ;
515+
516+ // Check replay `values` matches record `values`
517+ for ( a, b) in values. iter ( ) . zip ( result_values. iter ( ) ) {
518+ unsafe {
519+ assert ! ( a. assume_init( ) . as_bytes( ) == b. assume_init( ) . as_bytes( ) ) ;
520+ }
521+ }
510522 Ok ( ( ) )
511523 } ) ?;
512524
0 commit comments