33//! This module provides the [`ExecutionContext`] type, which holds global configuration
44//! relevant during the execution of commands in bootstrap. This includes dry-run
55//! mode, verbosity level, and behavior on failure.
6+ use std:: panic:: Location ;
67use std:: process:: Child ;
78use std:: sync:: { Arc , Mutex } ;
89
@@ -89,22 +90,23 @@ impl ExecutionContext {
8990 ) -> DeferredCommand < ' a > {
9091 command. mark_as_executed ( ) ;
9192
93+ let created_at = command. get_created_location ( ) ;
94+ let executed_at = std:: panic:: Location :: caller ( ) ;
95+
9296 if self . dry_run ( ) && !command. run_always {
9397 return DeferredCommand {
9498 process : None ,
9599 stdout,
96100 stderr,
97101 command,
98102 exec_ctx : Arc :: new ( self . clone ( ) ) ,
103+ created_at,
99104 } ;
100105 }
101106
102107 #[ cfg( feature = "tracing" ) ]
103108 let _run_span = trace_cmd ! ( command) ;
104109
105- let created_at = command. get_created_location ( ) ;
106- let executed_at = std:: panic:: Location :: caller ( ) ;
107-
108110 self . verbose ( || {
109111 println ! ( "running: {command:?} (created at {created_at}, executed at {executed_at})" )
110112 } ) ;
@@ -121,6 +123,7 @@ impl ExecutionContext {
121123 stderr,
122124 command,
123125 exec_ctx : Arc :: new ( self . clone ( ) ) ,
126+ created_at,
124127 }
125128 }
126129
@@ -167,6 +170,7 @@ pub struct DeferredCommand<'a> {
167170 stdout : OutputMode ,
168171 stderr : OutputMode ,
169172 exec_ctx : Arc < ExecutionContext > ,
173+ created_at : Location < ' a > ,
170174}
171175
172176impl < ' a > DeferredCommand < ' a > {
@@ -176,7 +180,7 @@ impl<'a> DeferredCommand<'a> {
176180 }
177181 let output = self . process . take ( ) . unwrap ( ) . wait_with_output ( ) ;
178182
179- let created_at = self . command . get_created_location ( ) ;
183+ let created_at = self . created_at ;
180184 let executed_at = std:: panic:: Location :: caller ( ) ;
181185
182186 use std:: fmt:: Write ;
0 commit comments