33// For the full copyright and license information, please view the LICENSE
44// file that was distributed with this source code.
55
6- #[ cfg( unix) ]
7- use nix:: unistd:: { read, write} ;
86#[ cfg( unix) ]
97use std:: fs:: File ;
108#[ cfg( unix) ]
119use std:: fs:: { Permissions , set_permissions} ;
10+ #[ cfg( unix) ]
11+ use std:: io:: { Read as _, Write as _} ;
1212#[ cfg( target_os = "linux" ) ]
1313use std:: os:: unix:: ffi:: OsStrExt ;
1414#[ cfg( unix) ]
@@ -23,8 +23,8 @@ fn run_more_with_pty(
2323 args : & [ & str ] ,
2424 file : & str ,
2525 content : & str ,
26- ) -> ( uutests:: util:: UChild , std :: os :: fd :: OwnedFd , String ) {
27- let ( path, controller, _replica) = pty_path ( ) ;
26+ ) -> ( uutests:: util:: UChild , File , String ) {
27+ let ( path, mut controller, _replica) = pty_path ( ) ;
2828 let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
2929 at. write ( file, content) ;
3030
@@ -37,15 +37,15 @@ fn run_more_with_pty(
3737
3838 child. delay ( 200 ) ;
3939 let mut output = vec ! [ 0u8 ; 1024 ] ;
40- let n = read ( & controller , & mut output) . unwrap ( ) ;
40+ let n = controller . read ( & mut output) . unwrap ( ) ;
4141 let output_str = String :: from_utf8_lossy ( & output[ ..n] ) . to_string ( ) ;
4242
4343 ( child, controller, output_str)
4444}
4545
4646#[ cfg( unix) ]
47- fn quit_more ( controller : & std :: os :: fd :: OwnedFd , mut child : uutests:: util:: UChild ) {
48- write ( controller, b"q" ) . unwrap ( ) ;
47+ fn quit_more ( controller : & mut File , mut child : uutests:: util:: UChild ) {
48+ controller. write_all ( b"q" ) . unwrap ( ) ;
4949 child. delay ( 50 ) ;
5050}
5151
@@ -88,7 +88,7 @@ fn test_valid_arg() {
8888#[ cfg( unix) ]
8989fn test_alive ( args : & [ & str ] ) {
9090 let ( at, mut ucmd) = at_and_ucmd ! ( ) ;
91- let ( path, controller, _replica) = pty_path ( ) ;
91+ let ( path, mut controller, _replica) = pty_path ( ) ;
9292
9393 let content = "test content" ;
9494 let file = "test_file" ;
@@ -107,7 +107,7 @@ fn test_alive(args: &[&str]) {
107107 assert ! ( child. is_alive( ) , "Command should still be alive" ) ;
108108
109109 // cleanup
110- write ( & controller, b"q" ) . unwrap ( ) ;
110+ controller. write_all ( b"q" ) . unwrap ( ) ;
111111 child. delay ( 50 ) ;
112112}
113113
@@ -217,39 +217,40 @@ fn test_more_non_utf8_paths() {
217217#[ test]
218218#[ cfg( unix) ]
219219fn test_basic_display ( ) {
220- let ( child, controller, output) = run_more_with_pty ( & [ ] , "test.txt" , "line1\n line2\n line3\n " ) ;
220+ let ( child, mut controller, output) =
221+ run_more_with_pty ( & [ ] , "test.txt" , "line1\n line2\n line3\n " ) ;
221222 assert ! ( output. contains( "line1" ) ) ;
222- quit_more ( & controller, child) ;
223+ quit_more ( & mut controller, child) ;
223224}
224225
225226#[ test]
226227#[ cfg( unix) ]
227228fn test_squeeze_blank_lines ( ) {
228- let ( child, controller, output) =
229+ let ( child, mut controller, output) =
229230 run_more_with_pty ( & [ "-s" ] , "test.txt" , "line1\n \n \n \n line2\n " ) ;
230231 assert ! ( output. contains( "line1" ) ) ;
231- quit_more ( & controller, child) ;
232+ quit_more ( & mut controller, child) ;
232233}
233234
234235#[ test]
235236#[ cfg( unix) ]
236237fn test_pattern_search ( ) {
237- let ( child, controller, output) = run_more_with_pty (
238+ let ( child, mut controller, output) = run_more_with_pty (
238239 & [ "-P" , "target" ] ,
239240 "test.txt" ,
240241 "foo\n bar\n baz\n target\n end\n " ,
241242 ) ;
242243 assert ! ( output. contains( "target" ) ) ;
243244 assert ! ( !output. contains( "foo" ) ) ;
244- quit_more ( & controller, child) ;
245+ quit_more ( & mut controller, child) ;
245246}
246247
247248#[ test]
248249#[ cfg( unix) ]
249250fn test_from_line_option ( ) {
250- let ( child, controller, output) =
251+ let ( child, mut controller, output) =
251252 run_more_with_pty ( & [ "-F" , "2" ] , "test.txt" , "line1\n line2\n line3\n line4\n " ) ;
252253 assert ! ( output. contains( "line2" ) ) ;
253254 assert ! ( !output. contains( "line1" ) ) ;
254- quit_more ( & controller, child) ;
255+ quit_more ( & mut controller, child) ;
255256}
0 commit comments