diff --git a/tests/util/server/src/pty.rs b/tests/util/server/src/pty.rs index d6102c1d63..5d8049fee9 100644 --- a/tests/util/server/src/pty.rs +++ b/tests/util/server/src/pty.rs @@ -9,8 +9,12 @@ use std::path::Path; use std::time::Duration; use std::time::Instant; +use once_cell::sync::Lazy; + use crate::strip_ansi_codes; +static IS_CI: Lazy = Lazy::new(|| std::env::var("CI").is_ok()); + /// Points to know about when writing pty tests: /// /// - Consecutive writes cause issues where you might write while a prompt @@ -54,7 +58,7 @@ impl Pty { pub fn is_supported() -> bool { let is_windows = cfg!(windows); - if is_windows && std::env::var("CI").is_ok() { + if is_windows && *IS_CI { // the pty tests don't really start up on the windows CI for some reason // so ignore them for now eprintln!("Ignoring windows CI."); @@ -209,7 +213,7 @@ impl Pty { #[track_caller] fn read_until_condition(&mut self, condition: impl FnMut(&mut Self) -> bool) { - let duration = if std::env::var_os("CI").is_some() { + let duration = if *IS_CI { Duration::from_secs(30) } else { Duration::from_secs(15) @@ -268,7 +272,12 @@ impl Pty { self.read_bytes.extend(&buf[..count]); } _ => { - std::thread::sleep(Duration::from_millis(15)); + // be a bit easier on the CI + std::thread::sleep(Duration::from_millis(if *IS_CI { + 100 + } else { + 20 + })); } } }