vim test redux (#11709)

This cleans up the neovim-backed vim tests:
- removed exempted tests (we'll rely on bug reports to find missing edge
cases)
- moved all assertions into non-async fn's so that failures are
reporting on the right file/line
- removed the NeovimBackedBindingTestContext
- renamed a few things to make them clearer
- reduced the number of permutations tested in some cases to reduce
slowest test from 60s to 5s

Release Notes:

- N/A
This commit is contained in:
Conrad Irwin 2024-05-11 12:04:05 -06:00 committed by GitHub
parent 48cba328f2
commit f550f23b97
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
38 changed files with 2311 additions and 6505 deletions

View file

@ -46,11 +46,11 @@ mod test {
#[gpui::test]
async fn test_enter_and_exit_insert_mode(cx: &mut gpui::TestAppContext) {
let mut cx = VimTestContext::new(cx, true).await;
cx.simulate_keystroke("i");
cx.simulate_keystrokes("i");
assert_eq!(cx.mode(), Mode::Insert);
cx.simulate_keystrokes(["T", "e", "s", "t"]);
cx.simulate_keystrokes("T e s t");
cx.assert_editor_state("Testˇ");
cx.simulate_keystroke("escape");
cx.simulate_keystrokes("escape");
assert_eq!(cx.mode(), Mode::Normal);
cx.assert_editor_state("Tesˇt");
}
@ -60,38 +60,32 @@ mod test {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state("ˇhello\n").await;
cx.simulate_shared_keystrokes(["5", "i", "-", "escape"])
.await;
cx.simulate_shared_keystrokes("5 i - escape").await;
cx.run_until_parked();
cx.assert_shared_state("----ˇ-hello\n").await;
cx.shared_state().await.assert_eq("----ˇ-hello\n");
cx.set_shared_state("ˇhello\n").await;
cx.simulate_shared_keystrokes(["5", "a", "-", "escape"])
.await;
cx.simulate_shared_keystrokes("5 a - escape").await;
cx.run_until_parked();
cx.assert_shared_state("h----ˇ-ello\n").await;
cx.shared_state().await.assert_eq("h----ˇ-ello\n");
cx.simulate_shared_keystrokes(["4", "shift-i", "-", "escape"])
.await;
cx.simulate_shared_keystrokes("4 shift-i - escape").await;
cx.run_until_parked();
cx.assert_shared_state("---ˇ-h-----ello\n").await;
cx.shared_state().await.assert_eq("---ˇ-h-----ello\n");
cx.simulate_shared_keystrokes(["3", "shift-a", "-", "escape"])
.await;
cx.simulate_shared_keystrokes("3 shift-a - escape").await;
cx.run_until_parked();
cx.assert_shared_state("----h-----ello--ˇ-\n").await;
cx.shared_state().await.assert_eq("----h-----ello--ˇ-\n");
cx.set_shared_state("ˇhello\n").await;
cx.simulate_shared_keystrokes(["3", "o", "o", "i", "escape"])
.await;
cx.simulate_shared_keystrokes("3 o o i escape").await;
cx.run_until_parked();
cx.assert_shared_state("hello\noi\noi\noˇi\n").await;
cx.shared_state().await.assert_eq("hello\noi\noi\noˇi\n");
cx.set_shared_state("ˇhello\n").await;
cx.simulate_shared_keystrokes(["3", "shift-o", "o", "i", "escape"])
.await;
cx.simulate_shared_keystrokes("3 shift-o o i escape").await;
cx.run_until_parked();
cx.assert_shared_state("oi\noi\noˇi\nhello\n").await;
cx.shared_state().await.assert_eq("oi\noi\noˇi\nhello\n");
}
#[gpui::test]
@ -99,27 +93,29 @@ mod test {
let mut cx = NeovimBackedTestContext::new(cx).await;
cx.set_shared_state("ˇhello\n").await;
cx.simulate_shared_keystrokes(["3", "i", "-", "escape"])
.await;
cx.simulate_shared_keystrokes("3 i - escape").await;
cx.run_until_parked();
cx.assert_shared_state("--ˇ-hello\n").await;
cx.simulate_shared_keystrokes(["."]).await;
cx.shared_state().await.assert_eq("--ˇ-hello\n");
cx.simulate_shared_keystrokes(".").await;
cx.run_until_parked();
cx.assert_shared_state("----ˇ--hello\n").await;
cx.simulate_shared_keystrokes(["2", "."]).await;
cx.shared_state().await.assert_eq("----ˇ--hello\n");
cx.simulate_shared_keystrokes("2 .").await;
cx.run_until_parked();
cx.assert_shared_state("-----ˇ---hello\n").await;
cx.shared_state().await.assert_eq("-----ˇ---hello\n");
cx.set_shared_state("ˇhello\n").await;
cx.simulate_shared_keystrokes(["2", "o", "k", "k", "escape"])
.await;
cx.simulate_shared_keystrokes("2 o k k escape").await;
cx.run_until_parked();
cx.assert_shared_state("hello\nkk\nkˇk\n").await;
cx.simulate_shared_keystrokes(["."]).await;
cx.shared_state().await.assert_eq("hello\nkk\nkˇk\n");
cx.simulate_shared_keystrokes(".").await;
cx.run_until_parked();
cx.assert_shared_state("hello\nkk\nkk\nkk\nkˇk\n").await;
cx.simulate_shared_keystrokes(["1", "."]).await;
cx.shared_state()
.await
.assert_eq("hello\nkk\nkk\nkk\nkˇk\n");
cx.simulate_shared_keystrokes("1 .").await;
cx.run_until_parked();
cx.assert_shared_state("hello\nkk\nkk\nkk\nkk\nkˇk\n").await;
cx.shared_state()
.await
.assert_eq("hello\nkk\nkk\nkk\nkk\nkˇk\n");
}
}