@@ -94,14 +94,7 @@ impl ExecutionContext {
9494 let executed_at = std:: panic:: Location :: caller ( ) ;
9595
9696 if self . dry_run ( ) && !command. run_always {
97- return DeferredCommand {
98- process : None ,
99- stdout,
100- stderr,
101- command,
102- exec_ctx : Arc :: new ( self . clone ( ) ) ,
103- created_at,
104- } ;
97+ return DeferredCommand { process : None , stdout, stderr, command, created_at } ;
10598 }
10699
107100 #[ cfg( feature = "tracing" ) ]
@@ -117,14 +110,7 @@ impl ExecutionContext {
117110
118111 let child = cmd. spawn ( ) . unwrap ( ) ;
119112
120- DeferredCommand {
121- process : Some ( child) ,
122- stdout,
123- stderr,
124- command,
125- exec_ctx : Arc :: new ( self . clone ( ) ) ,
126- created_at,
127- }
113+ DeferredCommand { process : Some ( child) , stdout, stderr, command, created_at }
128114 }
129115
130116 /// Execute a command and return its output.
@@ -137,7 +123,7 @@ impl ExecutionContext {
137123 stdout : OutputMode ,
138124 stderr : OutputMode ,
139125 ) -> CommandOutput {
140- self . start ( command, stdout, stderr) . wait_for_output ( )
126+ self . start ( command, stdout, stderr) . wait_for_output ( self )
141127 }
142128
143129 fn fail ( & self , message : & str , output : CommandOutput ) -> ! {
@@ -164,20 +150,28 @@ impl ExecutionContext {
164150 }
165151}
166152
153+ impl AsRef < ExecutionContext > for ExecutionContext {
154+ fn as_ref ( & self ) -> & ExecutionContext {
155+ self
156+ }
157+ }
158+
167159pub struct DeferredCommand < ' a > {
168160 process : Option < Child > ,
169161 command : & ' a mut BootstrapCommand ,
170162 stdout : OutputMode ,
171163 stderr : OutputMode ,
172- exec_ctx : Arc < ExecutionContext > ,
173164 created_at : Location < ' a > ,
174165}
175166
176167impl < ' a > DeferredCommand < ' a > {
177- pub fn wait_for_output ( mut self ) -> CommandOutput {
168+ pub fn wait_for_output ( mut self , exec_ctx : impl AsRef < ExecutionContext > ) -> CommandOutput {
178169 if self . process . is_none ( ) {
179170 return CommandOutput :: default ( ) ;
180171 }
172+
173+ let exec_ctx = exec_ctx. as_ref ( ) ;
174+
181175 let output = self . process . take ( ) . unwrap ( ) . wait_with_output ( ) ;
182176
183177 let created_at = self . created_at ;
@@ -234,14 +228,14 @@ Executed at: {executed_at}"#,
234228 if !output. is_success ( ) {
235229 match self . command . failure_behavior {
236230 BehaviorOnFailure :: DelayFail => {
237- if self . exec_ctx . fail_fast {
238- self . exec_ctx . fail ( & message, output) ;
231+ if exec_ctx. fail_fast {
232+ exec_ctx. fail ( & message, output) ;
239233 }
240234
241- self . exec_ctx . add_to_delay_failure ( message) ;
235+ exec_ctx. add_to_delay_failure ( message) ;
242236 }
243237 BehaviorOnFailure :: Exit => {
244- self . exec_ctx . fail ( & message, output) ;
238+ exec_ctx. fail ( & message, output) ;
245239 }
246240 BehaviorOnFailure :: Ignore => {
247241 // If failures are allowed, either the error has been printed already
0 commit comments