Skip to content

[meta] set far-future durations to 1 year instead #2462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions nextest-runner/src/config/slow_timeout.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) The nextest Contributors
// SPDX-License-Identifier: MIT OR Apache-2.0

use crate::time::far_future_duration;
use crate::time::one_year_duration;
use serde::{Deserialize, de::IntoDeserializer};
use std::{fmt, num::NonZeroUsize, time::Duration};

Expand All @@ -20,7 +20,7 @@ pub struct SlowTimeout {
impl SlowTimeout {
/// A reasonable value for "maximum slow timeout".
pub(crate) const VERY_LARGE: Self = Self {
period: far_future_duration(),
period: one_year_duration(),
terminate_after: None,
grace_period: Duration::from_secs(10),
};
Expand Down
2 changes: 1 addition & 1 deletion nextest-runner/src/runner/dispatcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ mod tests {
vec![],
0,
MaxFail::All,
crate::time::far_future_duration(),
crate::time::one_year_duration(),
);

cx.disable_signal_3_times_panic = true;
Expand Down
17 changes: 7 additions & 10 deletions nextest-runner/src/time/pausable_sleep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl PausableSleep {
SleepPauseState::Running => {
// Figure out how long there is until the deadline.
let deadline = this.sleep.deadline();
this.sleep.reset(far_future());
this.sleep.reset(one_year());
// This will return 0 if the deadline has passed. That's fine because we'll just
// reset the timer back to 0 in resume, which will behave correctly.
let remaining = deadline.duration_since(Instant::now());
Expand Down Expand Up @@ -124,17 +124,14 @@ enum SleepPauseState {
Paused { remaining: Duration },
}

// Cribbed from tokio.
fn far_future() -> Instant {
Instant::now() + far_future_duration()
fn one_year() -> Instant {
Instant::now() + one_year_duration()
}

pub(crate) const fn far_future_duration() -> Duration {
// Roughly 30 years from now.
// API does not provide a way to obtain max `Instant`
// or convert specific date in the future to instant.
// 1000 years overflows on macOS, 100 years overflows on FreeBSD.
Duration::from_secs(86400 * 365 * 30)
pub(crate) const fn one_year_duration() -> Duration {
// 365 days from now. Tokio's timer wheel's top level goes to 2 years, so 1
// year is half of that which should be suitable for this use case.
Duration::from_secs(86400 * 365)
}

#[cfg(test)]
Expand Down
Loading