mirror of
https://github.com/nushell/nushell.git
synced 2024-11-07 09:04:18 +01:00
Make the plugin persistence GC delay test more reliable (#12153)
# Description This makes the test a bit more complicated, but implements a timeout loop in the script. As long as the test completes in 5 seconds it's considered to be ok. The default is 10 seconds, so that would still be half that. This should help with running on the busy CI where things sometimes take a while. Unfortunately this is a timing sensitive test. The alternative is basically to just not test this at all because it's too difficult to guarantee that it will complete in time. If we continue to have issues, I might just have to take that route instead.
This commit is contained in:
parent
5596190377
commit
afce380530
@ -235,12 +235,24 @@ fn plugin_gc_can_be_configured_to_stop_plugins_after_delay() {
|
||||
r#"
|
||||
$env.config.plugin_gc = { default: { stop_after: 50ms } }
|
||||
"2.3.0" | inc -M
|
||||
sleep 100ms
|
||||
(plugin list | where name == inc).0.is_running
|
||||
let start = (date now)
|
||||
mut cond = true
|
||||
while $cond {
|
||||
sleep 100ms
|
||||
$cond = (
|
||||
(plugin list | where name == inc).0.is_running and
|
||||
((date now) - $start) < 5sec
|
||||
)
|
||||
}
|
||||
((date now) - $start) | into int
|
||||
"#
|
||||
);
|
||||
assert!(out.status.success());
|
||||
assert_eq!("false", out.out, "with config as default");
|
||||
let nanos = out.out.parse::<i64>().expect("not a number");
|
||||
assert!(
|
||||
nanos < 5_000_000_000,
|
||||
"with config as default: more than 5 seconds: {nanos} ns"
|
||||
);
|
||||
|
||||
let out = nu_with_plugins!(
|
||||
cwd: ".",
|
||||
@ -252,12 +264,24 @@ fn plugin_gc_can_be_configured_to_stop_plugins_after_delay() {
|
||||
}
|
||||
}
|
||||
"2.3.0" | inc -M
|
||||
sleep 100ms
|
||||
(plugin list | where name == inc).0.is_running
|
||||
let start = (date now)
|
||||
mut cond = true
|
||||
while $cond {
|
||||
sleep 100ms
|
||||
$cond = (
|
||||
(plugin list | where name == inc).0.is_running and
|
||||
((date now) - $start) < 5sec
|
||||
)
|
||||
}
|
||||
((date now) - $start) | into int
|
||||
"#
|
||||
);
|
||||
assert!(out.status.success());
|
||||
assert_eq!("false", out.out, "with inc-specific config");
|
||||
let nanos = out.out.parse::<i64>().expect("not a number");
|
||||
assert!(
|
||||
nanos < 5_000_000_000,
|
||||
"with inc-specific config: more than 5 seconds: {nanos} ns"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
Reference in New Issue
Block a user