@@ -816,12 +816,16 @@ pub fn write_report(report: &Value) -> Result<PathBuf, String> {
816816/// [`write_report`] with the directory lifted into a parameter, so the naming
817817/// and pruning are testable without writing into the real store.
818818fn write_report_into ( dir : & Path , report : & Value ) -> Result < PathBuf , String > {
819- std:: fs:: create_dir_all ( dir)
820- . map_err ( |error| format ! ( "Failed to create the diagnostics folder: {error}" ) ) ?;
821819 let stamp = SystemTime :: now ( )
822820 . duration_since ( UNIX_EPOCH )
823821 . map ( |since| since. as_secs ( ) )
824822 . unwrap_or ( 0 ) ;
823+ write_report_at ( dir, report, stamp)
824+ }
825+
826+ fn write_report_at ( dir : & Path , report : & Value , stamp : u64 ) -> Result < PathBuf , String > {
827+ std:: fs:: create_dir_all ( dir)
828+ . map_err ( |error| format ! ( "Failed to create the diagnostics folder: {error}" ) ) ?;
825829 // A run with no sidecar finishes in well under a second, so two of them
826830 // would otherwise write the same name and the second would overwrite the
827831 // first. The prefix and suffix stay exactly as the pruning filter expects.
@@ -1194,8 +1198,9 @@ mod tests {
11941198 #[ test]
11951199 fn reports_in_the_same_second_do_not_collide ( ) {
11961200 let dir = temp_dir ( "collide" ) ;
1197- let first = write_report_into ( & dir, & json ! ( { "first" : true } ) ) . unwrap ( ) ;
1198- let second = write_report_into ( & dir, & json ! ( { "second" : true } ) ) . unwrap ( ) ;
1201+ let at = 1_792_431_796 ;
1202+ let first = write_report_at ( & dir, & json ! ( { "first" : true } ) , at) . unwrap ( ) ;
1203+ let second = write_report_at ( & dir, & json ! ( { "second" : true } ) , at) . unwrap ( ) ;
11991204
12001205 assert_ne ! ( first, second) ;
12011206 assert ! ( first. exists( ) && second. exists( ) ) ;
@@ -1206,8 +1211,8 @@ mod tests {
12061211 // Both parse back to the same second, so pruning still orders by time
12071212 // first and falls back to the name.
12081213 let stamp = |path : & Path | report_file_stamp ( path. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ) ;
1209- assert_eq ! ( stamp( & first) , stamp ( & second ) ) ;
1210- assert ! ( stamp( & first ) . is_some_and ( |secs| secs > 0 ) ) ;
1214+ assert_eq ! ( stamp( & first) , Some ( at ) ) ;
1215+ assert_eq ! ( stamp( & second ) , Some ( at ) ) ;
12111216
12121217 std:: fs:: remove_dir_all ( & dir) . ok ( ) ;
12131218 }
0 commit comments