Skip to content

Commit

Permalink
remove test loop
Browse files Browse the repository at this point in the history
  • Loading branch information
conradludgate committed Feb 13, 2024
1 parent 2d93e53 commit de8ab90
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions tokio/tests/rt_metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ fn active_tasks_count() {
}))
.unwrap();

assert_eq!(0, rt.metrics().active_tasks_count());

let rt = threaded();
let metrics = rt.metrics();
assert_eq!(0, metrics.active_tasks_count());
rt.block_on(rt.spawn(async move {
assert_eq!(1, metrics.active_tasks_count());
}))
.unwrap();

assert_eq!(0, rt.metrics().active_tasks_count());
}

#[test]
Expand All @@ -122,14 +126,7 @@ fn spawned_tasks_count() {
}))
.unwrap();

for _ in 0..100 {
if rt.metrics().spawned_tasks_count() == 1 {
return;
}
// on single threaded machines (like in CI), we need to force the OS to run the runtime threads
std::thread::sleep(std::time::Duration::from_millis(1));
}
panic!("runtime didn't decrement active task gauge")
assert_eq!(1, rt.metrics().spawned_tasks_count());
}

#[test]
Expand Down

0 comments on commit de8ab90

Please sign in to comment.