Skip to content

Commit 186f588

Browse files
committed
change to executed at
1 parent 55e2c26 commit 186f588

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/bootstrap/src/utils/exec.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
//!
33
//! This module provides a structured way to execute and manage commands efficiently,
44
//! ensuring controlled failure handling and output management.
5-
#![allow(warnings)]
65
use std::ffi::OsStr;
76
use std::fmt::{Debug, Formatter};
87
use std::path::Path;
9-
use std::process::{Child, Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio};
8+
use std::process::{Command, CommandArgs, CommandEnvs, ExitStatus, Output, Stdio};
109

1110
use build_helper::ci::CiEnv;
1211
use build_helper::drop_bomb::DropBomb;
@@ -73,7 +72,7 @@ pub struct BootstrapCommand {
7372
drop_bomb: DropBomb,
7473
}
7574

76-
impl BootstrapCommand {
75+
impl<'a> BootstrapCommand {
7776
#[track_caller]
7877
pub fn new<S: AsRef<OsStr>>(program: S) -> Self {
7978
Command::new(program).into()
@@ -160,16 +159,19 @@ impl BootstrapCommand {
160159

161160
/// Spawn the command in background, while capturing and returning all its output.
162161
#[track_caller]
163-
pub fn start_capture(&mut self, exec_ctx: impl AsRef<ExecutionContext>) -> DeferredCommand {
162+
pub fn start_capture(
163+
&'a mut self,
164+
exec_ctx: impl AsRef<ExecutionContext>,
165+
) -> DeferredCommand<'a> {
164166
exec_ctx.as_ref().start(self, OutputMode::Capture, OutputMode::Capture)
165167
}
166168

167169
/// Spawn the command in background, while capturing and returning stdout, and printing stderr.
168170
#[track_caller]
169171
pub fn start_capture_stdout(
170-
&mut self,
172+
&'a mut self,
171173
exec_ctx: impl AsRef<ExecutionContext>,
172-
) -> DeferredCommand {
174+
) -> DeferredCommand<'a> {
173175
exec_ctx.as_ref().start(self, OutputMode::Capture, OutputMode::Print)
174176
}
175177

src/bootstrap/src/utils/execution_context.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ impl ExecutionContext {
9494
let executed_at = std::panic::Location::caller();
9595

9696
if self.dry_run() && !command.run_always {
97-
return DeferredCommand { process: None, stdout, stderr, command, created_at };
97+
return DeferredCommand { process: None, stdout, stderr, command, executed_at };
9898
}
9999

100100
#[cfg(feature = "tracing")]
@@ -110,7 +110,7 @@ impl ExecutionContext {
110110

111111
let child = cmd.spawn().unwrap();
112112

113-
DeferredCommand { process: Some(child), stdout, stderr, command, created_at }
113+
DeferredCommand { process: Some(child), stdout, stderr, command, executed_at }
114114
}
115115

116116
/// Execute a command and return its output.
@@ -161,7 +161,7 @@ pub struct DeferredCommand<'a> {
161161
command: &'a mut BootstrapCommand,
162162
stdout: OutputMode,
163163
stderr: OutputMode,
164-
created_at: Location<'a>,
164+
executed_at: &'a Location<'a>,
165165
}
166166

167167
impl<'a> DeferredCommand<'a> {
@@ -174,8 +174,8 @@ impl<'a> DeferredCommand<'a> {
174174

175175
let output = self.process.take().unwrap().wait_with_output();
176176

177-
let created_at = self.created_at;
178-
let executed_at = std::panic::Location::caller();
177+
let created_at = self.command.get_created_location();
178+
let executed_at = self.executed_at;
179179

180180
use std::fmt::Write;
181181

0 commit comments

Comments
 (0)