@@ -604,7 +604,7 @@ pub(crate) fn write_file_recorded(
604
604
let hash = Sha256 :: new ( ) . chain_update ( content. as_ref ( ) ) . finalize ( ) ;
605
605
let encoded_hash = format ! ( "sha256={}" , BASE64URL_NOPAD . encode( & hash) ) ;
606
606
record. push ( RecordEntry {
607
- path : relative_path. display ( ) . to_string ( ) ,
607
+ path : relative_path. portable_display ( ) . to_string ( ) ,
608
608
hash : Some ( encoded_hash) ,
609
609
size : Some ( content. as_ref ( ) . len ( ) as u64 ) ,
610
610
} ) ;
@@ -741,7 +741,8 @@ mod test {
741
741
use crate :: Error ;
742
742
743
743
use super :: {
744
- get_script_executable, parse_email_message_file, parse_wheel_file, read_record_file, Script ,
744
+ get_script_executable, parse_email_message_file, parse_wheel_file, read_record_file,
745
+ write_installer_metadata, Script , RecordEntry ,
745
746
} ;
746
747
747
748
#[ test]
@@ -1016,4 +1017,33 @@ mod test {
1016
1017
1017
1018
Ok ( ( ) )
1018
1019
}
1020
+
1021
+ #[ test]
1022
+ fn test_write_installer_metadata ( ) {
1023
+ let temp_dir = assert_fs:: TempDir :: new ( ) . unwrap ( ) ;
1024
+ let site_packages = temp_dir. path ( ) ;
1025
+ let mut record: Vec < RecordEntry > = Vec :: new ( ) ;
1026
+ temp_dir. child ( "foo-0.1.0.dist-info" ) . create_dir_all ( ) . unwrap ( ) ;
1027
+ write_installer_metadata (
1028
+ site_packages,
1029
+ "foo-0.1.0" ,
1030
+ true ,
1031
+ None ,
1032
+ None ,
1033
+ Some ( "uv" ) ,
1034
+ & mut record,
1035
+ )
1036
+ . unwrap ( ) ;
1037
+ let expected = [
1038
+ "foo-0.1.0.dist-info/REQUESTED" ,
1039
+ "foo-0.1.0.dist-info/INSTALLER" ,
1040
+ ]
1041
+ . map ( ToString :: to_string)
1042
+ . to_vec ( ) ;
1043
+ let actual = record
1044
+ . into_iter ( )
1045
+ . map ( |entry| entry. path )
1046
+ . collect :: < Vec < String > > ( ) ;
1047
+ assert_eq ! ( expected, actual) ;
1048
+ }
1019
1049
}
0 commit comments