Skip to content

Commit ee110a1

Browse files
committed
restructure try_run_tests
1 parent 3ab6f78 commit ee110a1

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

src/bootstrap/src/utils/exec.rs

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,15 @@ impl<'a> BootstrapCommand {
211211
exec_ctx.as_ref().start(self, OutputMode::Capture, OutputMode::Print)
212212
}
213213

214+
/// Spawn the command in background, while capturing and returns a handle to stream the output.
215+
#[track_caller]
216+
pub fn stream_capture(
217+
&'a mut self,
218+
exec_ctx: impl AsRef<ExecutionContext>,
219+
) -> Option<StreamingCommand> {
220+
exec_ctx.as_ref().stream(self, OutputMode::Capture, OutputMode::Capture)
221+
}
222+
214223
/// Spawn the command in background, while capturing and returning stdout, and printing stderr.
215224
#[track_caller]
216225
pub fn stream_capture_stdout(
@@ -222,7 +231,7 @@ impl<'a> BootstrapCommand {
222231

223232
/// Mark the command as being executed, disarming the drop bomb.
224233
/// If this method is not called before the command is dropped, its drop will panic.
225-
fn mark_as_executed(&mut self) {
234+
pub fn mark_as_executed(&mut self) {
226235
self.drop_bomb.defuse();
227236
}
228237

@@ -624,18 +633,12 @@ impl ExecutionContext {
624633
exit!(1);
625634
}
626635

627-
<<<<<<< HEAD
628-
pub fn stream<'a>(
629-
=======
630636
/// Spawns the command with configured stdout and stderr handling.
631637
///
632-
/// Returns `None` if in dry-run mode and the command is not allowed to run.
633-
///
634-
/// Panics if the command fails to spawn.
638+
/// Returns None if in dry-run mode or Panics if the command fails to spawn.
635639
pub fn stream(
636-
>>>>>>> c2e83361cec (add comment to exec)
637640
&self,
638-
command: &'a mut BootstrapCommand,
641+
command: &mut BootstrapCommand,
639642
stdout: OutputMode,
640643
stderr: OutputMode,
641644
) -> Option<StreamingCommand> {
@@ -654,7 +657,7 @@ impl ExecutionContext {
654657

655658
let stdout = child.stdout.take();
656659
let stderr = child.stderr.take();
657-
Some(StreamingCommand { child, stdout, stderr })
660+
return Some(StreamingCommand { child, stdout, stderr });
658661
}
659662
}
660663

src/bootstrap/src/utils/render_tests.rs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ pub(crate) fn try_run_tests(
3434
cmd: &mut BootstrapCommand,
3535
stream: bool,
3636
) -> bool {
37-
if !run_tests(builder, cmd, stream) {
38-
if builder.fail_fast {
39-
crate::exit!(1);
40-
} else {
41-
builder.config.exec_ctx().add_to_delay_failure(format!("{cmd:?}"));
42-
false
43-
}
44-
} else {
45-
true
37+
if run_tests(builder, cmd, stream) {
38+
return true;
4639
}
40+
41+
if builder.fail_fast {
42+
crate::exit!(1);
43+
}
44+
45+
builder.config.exec_ctx().add_to_delay_failure(format!("{cmd:?}"));
46+
47+
false
4748
}
4849

4950
fn run_tests(builder: &Builder<'_>, cmd: &mut BootstrapCommand, stream: bool) -> bool {

0 commit comments

Comments
 (0)