Skip to content

Commit

Permalink
fix a flaky test in cmdline package
Browse files Browse the repository at this point in the history
  • Loading branch information
itchyny committed Oct 7, 2024
1 parent a092854 commit d3c3157
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions cmdline/cmdline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestCmdlineRun(t *testing.T) {
go c.Run()
events := []event.Event{
{Type: event.StartCmdlineCommand},
{Type: event.Nop},
{Type: event.Rune, Rune: 't'},
{Type: event.Rune, Rune: 'e'},
{Type: event.CursorLeft},
Expand All @@ -50,22 +49,27 @@ func TestCmdlineRun(t *testing.T) {
cmdlineCh <- e
}
}()
for range len(events) - 4 {
for range len(events) - 3 {
<-redrawCh
}
e := <-eventCh
if e.Type != event.Error {
t.Errorf("cmdline should emit Error event but got %v", e)
}
<-redrawCh
cmdline, cursor, _, _ := c.Get()
if expected := "te"; string(cmdline) != expected {
t.Errorf("cmdline should be %q got %q", expected, string(cmdline))
}
if cursor != 2 {
t.Errorf("cursor should be 2 but got %v", cursor)
}
<-redrawCh
for range 3 {
<-redrawCh
}
cmdline, _, _, _ = c.Get()
if expected := ""; string(cmdline) != expected {
t.Errorf("cmdline should be %q got %q", expected, string(cmdline))
}
}

func TestCmdlineCursorMotion(t *testing.T) {
Expand Down

0 comments on commit d3c3157

Please sign in to comment.