Skip to content

Commit 866587b

Browse files
committed
[nextest-runner] return env map as part of InternalSetupScriptExecuteStatus
Carrying around a second parameter doesn't seem very useful.
1 parent fb888d1 commit 866587b

File tree

1 file changed

+41
-41
lines changed

1 file changed

+41
-41
lines changed

nextest-runner/src/runner.rs

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -547,10 +547,10 @@ impl<'a> TestRunnerInner<'a> {
547547
config,
548548
};
549549

550-
let (status, env_map) = self
550+
let status = self
551551
.run_setup_script(packet, &this_resp_tx, &mut req_rx)
552552
.await;
553-
let status = status.into_external();
553+
let (status, env_map) = status.into_external();
554554

555555
let _ = this_resp_tx.send(InternalTestEvent::SetupScriptFinished {
556556
script_id,
@@ -762,24 +762,21 @@ impl<'a> TestRunnerInner<'a> {
762762
script: SetupScriptPacket<'a>,
763763
resp_tx: &UnboundedSender<InternalTestEvent<'a>>,
764764
req_rx: &mut UnboundedReceiver<RunUnitRequest>,
765-
) -> (InternalSetupScriptExecuteStatus, Option<SetupScriptEnvMap>) {
765+
) -> InternalSetupScriptExecuteStatus {
766766
let mut stopwatch = crate::time::stopwatch();
767767

768768
match self
769769
.run_setup_script_inner(script, &mut stopwatch, resp_tx, req_rx)
770770
.await
771771
{
772-
Ok((status, env_map)) => (status, env_map),
773-
Err(error) => (
774-
InternalSetupScriptExecuteStatus {
775-
output: ChildExecutionResult::StartError(error),
776-
result: ExecutionResult::ExecFail,
777-
stopwatch_end: stopwatch.snapshot(),
778-
is_slow: false,
779-
env_count: 0,
780-
},
781-
None,
782-
),
772+
Ok(status) => status,
773+
Err(error) => InternalSetupScriptExecuteStatus {
774+
output: ChildExecutionResult::StartError(error),
775+
result: ExecutionResult::ExecFail,
776+
stopwatch_end: stopwatch.snapshot(),
777+
is_slow: false,
778+
env_map: None,
779+
},
783780
}
784781
}
785782

@@ -789,8 +786,7 @@ impl<'a> TestRunnerInner<'a> {
789786
stopwatch: &mut StopwatchStart,
790787
resp_tx: &UnboundedSender<InternalTestEvent<'a>>,
791788
req_rx: &mut UnboundedReceiver<RunUnitRequest>,
792-
) -> Result<(InternalSetupScriptExecuteStatus, Option<SetupScriptEnvMap>), ChildStartError>
793-
{
789+
) -> Result<InternalSetupScriptExecuteStatus, ChildStartError> {
794790
let mut cmd = script.make_command(&self.double_spawn, self.test_list)?;
795791
let command_mut = cmd.command_mut();
796792

@@ -964,22 +960,19 @@ impl<'a> TestRunnerInner<'a> {
964960
None
965961
};
966962

967-
Ok((
968-
InternalSetupScriptExecuteStatus {
969-
output: ChildExecutionResult::Output {
970-
output: child_acc.output.freeze(),
971-
errors: ErrorList::new(
972-
ChildExecutionResult::WAITING_ON_SETUP_SCRIPT_MESSAGE,
973-
errors,
974-
),
975-
},
976-
result: status,
977-
stopwatch_end: stopwatch.snapshot(),
978-
is_slow,
979-
env_count: env_map.as_ref().map(|map| map.len()).unwrap_or(0),
963+
Ok(InternalSetupScriptExecuteStatus {
964+
output: ChildExecutionResult::Output {
965+
output: child_acc.output.freeze(),
966+
errors: ErrorList::new(
967+
ChildExecutionResult::WAITING_ON_SETUP_SCRIPT_MESSAGE,
968+
errors,
969+
),
980970
},
971+
result: status,
972+
stopwatch_end: stopwatch.snapshot(),
973+
is_slow,
981974
env_map,
982-
))
975+
})
983976
}
984977

985978
/// Run an individual test in its own process.
@@ -1524,27 +1517,34 @@ pub struct SetupScriptExecuteStatus {
15241517
/// Whether this script counts as slow.
15251518
pub is_slow: bool,
15261519
/// The number of environment variables that were set by this script.
1527-
pub env_count: usize,
1520+
///
1521+
/// `None` if an error occurred while running the script or reading the
1522+
/// environment map.
1523+
pub env_count: Option<usize>,
15281524
}
15291525

15301526
struct InternalSetupScriptExecuteStatus {
15311527
output: ChildExecutionResult,
15321528
result: ExecutionResult,
15331529
stopwatch_end: StopwatchSnapshot,
15341530
is_slow: bool,
1535-
env_count: usize,
1531+
env_map: Option<SetupScriptEnvMap>,
15361532
}
15371533

15381534
impl InternalSetupScriptExecuteStatus {
1539-
fn into_external(self) -> SetupScriptExecuteStatus {
1540-
SetupScriptExecuteStatus {
1541-
output: self.output,
1542-
result: self.result,
1543-
start_time: self.stopwatch_end.start_time.fixed_offset(),
1544-
time_taken: self.stopwatch_end.active,
1545-
is_slow: self.is_slow,
1546-
env_count: self.env_count,
1547-
}
1535+
fn into_external(self) -> (SetupScriptExecuteStatus, Option<SetupScriptEnvMap>) {
1536+
let env_count = self.env_map.as_ref().map(|map| map.len());
1537+
(
1538+
SetupScriptExecuteStatus {
1539+
output: self.output,
1540+
result: self.result,
1541+
start_time: self.stopwatch_end.start_time.fixed_offset(),
1542+
time_taken: self.stopwatch_end.active,
1543+
is_slow: self.is_slow,
1544+
env_count,
1545+
},
1546+
self.env_map,
1547+
)
15481548
}
15491549
}
15501550

0 commit comments

Comments
 (0)