File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
src/tools/run-make-support/src Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 11use std:: env;
2+ use std:: io:: Write ;
23use std:: path:: Path ;
3- use std:: process:: { Command , Output } ;
4+ use std:: process:: { Command , Output , Stdio } ;
45
56use crate :: { handle_failed_output, set_host_rpath} ;
67
@@ -62,6 +63,26 @@ impl Rustdoc {
6263 self
6364 }
6465
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+
6586 #[ track_caller]
6687 pub fn run_fail_assert_exit_code ( & mut self , code : i32 ) -> Output {
6788 let caller_location = std:: panic:: Location :: caller ( ) ;
You can’t perform that action at this time.
0 commit comments