@@ -12,6 +12,7 @@ use crate::compute_diff::{write_diff, write_filtered_diff};
12
12
use crate :: errors:: { self , Error , ErrorKind } ;
13
13
use crate :: header:: TestProps ;
14
14
use crate :: json;
15
+ use crate :: read2:: read2_abbreviated;
15
16
use crate :: util:: get_pointer_width;
16
17
use crate :: util:: { logv, PathBufExt } ;
17
18
use crate :: ColorConfig ;
@@ -27,7 +28,7 @@ use std::hash::{Hash, Hasher};
27
28
use std:: io:: prelude:: * ;
28
29
use std:: io:: { self , BufReader } ;
29
30
use std:: path:: { Path , PathBuf } ;
30
- use std:: process:: { Child , Command , ExitStatus , Output , Stdio } ;
31
+ use std:: process:: { Command , ExitStatus , Output , Stdio } ;
31
32
use std:: str;
32
33
33
34
use glob:: glob;
@@ -3820,72 +3821,3 @@ enum AllowUnused {
3820
3821
Yes ,
3821
3822
No ,
3822
3823
}
3823
-
3824
- fn read2_abbreviated ( mut child : Child ) -> io:: Result < Output > {
3825
- use crate :: read2:: read2;
3826
- use std:: mem:: replace;
3827
-
3828
- const HEAD_LEN : usize = 160 * 1024 ;
3829
- const TAIL_LEN : usize = 256 * 1024 ;
3830
-
3831
- enum ProcOutput {
3832
- Full ( Vec < u8 > ) ,
3833
- Abbreviated { head : Vec < u8 > , skipped : usize , tail : Box < [ u8 ] > } ,
3834
- }
3835
-
3836
- impl ProcOutput {
3837
- fn extend ( & mut self , data : & [ u8 ] ) {
3838
- let new_self = match * self {
3839
- ProcOutput :: Full ( ref mut bytes) => {
3840
- bytes. extend_from_slice ( data) ;
3841
- let new_len = bytes. len ( ) ;
3842
- if new_len <= HEAD_LEN + TAIL_LEN {
3843
- return ;
3844
- }
3845
- let tail = bytes. split_off ( new_len - TAIL_LEN ) . into_boxed_slice ( ) ;
3846
- let head = replace ( bytes, Vec :: new ( ) ) ;
3847
- let skipped = new_len - HEAD_LEN - TAIL_LEN ;
3848
- ProcOutput :: Abbreviated { head, skipped, tail }
3849
- }
3850
- ProcOutput :: Abbreviated { ref mut skipped, ref mut tail, .. } => {
3851
- * skipped += data. len ( ) ;
3852
- if data. len ( ) <= TAIL_LEN {
3853
- tail[ ..data. len ( ) ] . copy_from_slice ( data) ;
3854
- tail. rotate_left ( data. len ( ) ) ;
3855
- } else {
3856
- tail. copy_from_slice ( & data[ ( data. len ( ) - TAIL_LEN ) ..] ) ;
3857
- }
3858
- return ;
3859
- }
3860
- } ;
3861
- * self = new_self;
3862
- }
3863
-
3864
- fn into_bytes ( self ) -> Vec < u8 > {
3865
- match self {
3866
- ProcOutput :: Full ( bytes) => bytes,
3867
- ProcOutput :: Abbreviated { mut head, skipped, tail } => {
3868
- write ! ( & mut head, "\n \n <<<<<< SKIPPED {} BYTES >>>>>>\n \n " , skipped) . unwrap ( ) ;
3869
- head. extend_from_slice ( & tail) ;
3870
- head
3871
- }
3872
- }
3873
- }
3874
- }
3875
-
3876
- let mut stdout = ProcOutput :: Full ( Vec :: new ( ) ) ;
3877
- let mut stderr = ProcOutput :: Full ( Vec :: new ( ) ) ;
3878
-
3879
- drop ( child. stdin . take ( ) ) ;
3880
- read2 (
3881
- child. stdout . take ( ) . unwrap ( ) ,
3882
- child. stderr . take ( ) . unwrap ( ) ,
3883
- & mut |is_stdout, data, _| {
3884
- if is_stdout { & mut stdout } else { & mut stderr } . extend ( data) ;
3885
- data. clear ( ) ;
3886
- } ,
3887
- ) ?;
3888
- let status = child. wait ( ) ?;
3889
-
3890
- Ok ( Output { status, stdout : stdout. into_bytes ( ) , stderr : stderr. into_bytes ( ) } )
3891
- }
0 commit comments