File tree 1 file changed +22
-1
lines changed
src/tools/run-make-support/src
1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1
1
use std:: env;
2
+ use std:: io:: Write ;
2
3
use std:: path:: Path ;
3
- use std:: process:: { Command , Output } ;
4
+ use std:: process:: { Command , Output , Stdio } ;
4
5
5
6
use crate :: { handle_failed_output, set_host_rpath} ;
6
7
@@ -62,6 +63,26 @@ impl Rustdoc {
62
63
self
63
64
}
64
65
66
+ /// Run the constructed command and assert that it is successfully run.
67
+ #[ track_caller]
68
+ pub fn run_with_stdin < I : AsRef < [ u8 ] > > ( & mut self , input : I ) -> :: std:: process:: Output {
69
+ let caller_location = :: std:: panic:: Location :: caller ( ) ;
70
+ let caller_line_number = caller_location. line ( ) ;
71
+
72
+ self . cmd . stdin ( Stdio :: piped ( ) ) ;
73
+ let mut child = self . cmd . spawn ( ) . unwrap ( ) ;
74
+ let mut stdin = child. stdin . take ( ) . unwrap ( ) ;
75
+ stdin. write_all ( input. as_ref ( ) ) . unwrap ( ) ;
76
+ drop ( stdin) ;
77
+
78
+ let output = child. wait_with_output ( ) . unwrap ( ) ;
79
+
80
+ if !output. status . success ( ) {
81
+ handle_failed_output ( & self . cmd , output, caller_line_number) ;
82
+ }
83
+ output
84
+ }
85
+
65
86
#[ track_caller]
66
87
pub fn run_fail_assert_exit_code ( & mut self , code : i32 ) -> Output {
67
88
let caller_location = std:: panic:: Location :: caller ( ) ;
You can’t perform that action at this time.
0 commit comments