File tree Expand file tree Collapse file tree 2 files changed +32
-1
lines changed
helix-term/tests/test/commands Expand file tree Collapse file tree 2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -933,3 +933,33 @@ async fn test_move_file_when_given_dir_only() -> anyhow::Result<()> {
933933
934934 Ok ( ( ) )
935935}
936+
937+ #[ tokio:: test( flavor = "multi_thread" ) ]
938+ #[ cfg( unix) ]
939+ async fn test_write_ownership ( ) -> anyhow:: Result < ( ) > {
940+ // GH CI does not possess CAP_CHOWN
941+ if option_env ! ( "GITHUB_ACTIONS" ) . is_some ( ) {
942+ return Ok ( ( ) ) ;
943+ }
944+ use std:: os:: unix:: fs:: MetadataExt ;
945+
946+ let mut file = tempfile:: NamedTempFile :: new ( ) ?;
947+ let mut app = helpers:: AppBuilder :: new ( )
948+ . with_file ( file. path ( ) , None )
949+ . build ( ) ?;
950+
951+ let nobody_uid = 9999 ;
952+ let nogroup_gid = 9999 ;
953+
954+ helix_stdx:: faccess:: fchown ( & file. as_file_mut ( ) , Some ( nobody_uid) , Some ( nogroup_gid) ) ?;
955+
956+ let old_meta = file. as_file ( ) . metadata ( ) ?;
957+
958+ test_key_sequence ( & mut app, Some ( "hello:w<ret>" ) , None , false ) . await ?;
959+ reload_file ( & mut file) . unwrap ( ) ;
960+
961+ let new_meta = file. as_file ( ) . metadata ( ) ?;
962+ assert ! ( old_meta. uid( ) == new_meta. uid( ) && old_meta. gid( ) == new_meta. gid( ) ) ;
963+
964+ Ok ( ( ) )
965+ }
Original file line number Diff line number Diff line change @@ -1200,7 +1200,7 @@ impl Document {
12001200 open_opt. mode ( mode) ;
12011201 }
12021202
1203- let file = open_opt. open ( & path) . await ?;
1203+ let mut file = open_opt. open ( & path) . await ?;
12041204
12051205 #[ cfg( unix) ]
12061206 {
@@ -1221,6 +1221,7 @@ impl Document {
12211221 use std:: fs:: { File , FileTimes } ;
12221222 use std:: os:: macos:: fs:: FileTimesExt ;
12231223
1224+ let file = file. try_clone ( ) ?. into_std ( ) ;
12241225 let times = FileTimes :: new ( ) . set_created ( meta. created ( ) ?) ;
12251226 file. set_times ( times) ?;
12261227 }
You can’t perform that action at this time.
0 commit comments