From f891d1649360d1aa183a11d4ee36cf6ff3782354 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Wed, 22 May 2024 10:13:37 -0400 Subject: [PATCH] chore(repl): maybe improve repl test flakiness on the CI (#23933) These repl tests are still a bit flaky. Let's try this. https://github.com/denoland/deno/actions/runs/9176525869/job/25232001263 --- tests/util/server/src/pty.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) 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 + })); } } }