From 19495eb9bbfa874647e7bc69e0fdff49d68b1dcf Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 3 Nov 2024 15:14:35 +0900 Subject: Remove possible races (#4070) --- src/reader_test.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/reader_test.go') diff --git a/src/reader_test.go b/src/reader_test.go index 56f9a1b0..cab4c017 100644 --- a/src/reader_test.go +++ b/src/reader_test.go @@ -23,8 +23,12 @@ func TestReadFromCommand(t *testing.T) { } // Normal command - reader.fin(reader.readFromCommand(`echo abc&&echo def`, nil)) - if len(strs) != 2 || strs[0] != "abc" || strs[1] != "def" { + counter := 0 + ready := func() { + counter++ + } + reader.fin(reader.readFromCommand(`echo abc&&echo def`, nil, ready)) + if len(strs) != 2 || strs[0] != "abc" || strs[1] != "def" || counter != 1 { t.Errorf("%s", strs) } @@ -48,9 +52,9 @@ func TestReadFromCommand(t *testing.T) { reader.startEventPoller() // Failing command - reader.fin(reader.readFromCommand(`no-such-command`, nil)) + reader.fin(reader.readFromCommand(`no-such-command`, nil, ready)) strs = []string{} - if len(strs) > 0 { + if len(strs) > 0 || counter != 2 { t.Errorf("%s", strs) } -- cgit v1.2.3