From f22d53eef9198e64d7e1c72d7d3875af21727e26 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Wed, 6 Sep 2023 14:14:49 -0600 Subject: [PATCH] Make test more deterministic Otherwise these pass only when --features=neovim is set --- crates/vim/src/normal/repeat.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/vim/src/normal/repeat.rs b/crates/vim/src/normal/repeat.rs index 20b9966a41..7f2b8c4434 100644 --- a/crates/vim/src/normal/repeat.rs +++ b/crates/vim/src/normal/repeat.rs @@ -71,7 +71,7 @@ mod test { }; #[gpui::test] - async fn test_dot_repeat(cx: &mut gpui::TestAppContext) { + async fn test_dot_repeat(deterministic: Arc, cx: &mut gpui::TestAppContext) { let mut cx = NeovimBackedTestContext::new(cx).await; // "o" @@ -80,26 +80,33 @@ mod test { .await; cx.assert_shared_state("hello\nworlˇd").await; cx.simulate_shared_keystrokes(["."]).await; + deterministic.run_until_parked(); cx.assert_shared_state("hello\nworld\nworlˇd").await; // "d" cx.simulate_shared_keystrokes(["^", "d", "f", "o"]).await; cx.simulate_shared_keystrokes(["g", "g", "."]).await; + deterministic.run_until_parked(); cx.assert_shared_state("ˇ\nworld\nrld").await; // "p" (note that it pastes the current clipboard) cx.simulate_shared_keystrokes(["j", "y", "y", "p"]).await; cx.simulate_shared_keystrokes(["shift-g", "y", "y", "."]) .await; + deterministic.run_until_parked(); cx.assert_shared_state("\nworld\nworld\nrld\nˇrld").await; // "~" (note that counts apply to the action taken, not . itself) cx.set_shared_state("ˇthe quick brown fox").await; cx.simulate_shared_keystrokes(["2", "~", "."]).await; + deterministic.run_until_parked(); cx.set_shared_state("THE ˇquick brown fox").await; cx.simulate_shared_keystrokes(["3", "."]).await; + deterministic.run_until_parked(); cx.set_shared_state("THE QUIˇck brown fox").await; + deterministic.run_until_parked(); cx.simulate_shared_keystrokes(["."]).await; + deterministic.run_until_parked(); cx.set_shared_state("THE QUICK ˇbrown fox").await; }