Skip to content

Commit

Permalink
run concurrent processes test case with multiple goroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Feb 18, 2024
1 parent 9eb8b7b commit 5281740
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,23 @@ func TestProcessErrorLinterFailed(t *testing.T) {

func TestProcessRunConcurrentlyAndWait(t *testing.T) {
p := newConcurrentProcess(2)
ls := testSkipIfNoCommand(t, p, "ls")
echo := testSkipIfNoCommand(t, p, "echo")

c := make(chan struct{})
go func() {
for i := 0; i < 5; i++ {
ls.run(nil, "", func(b []byte, err error) error {
return err
})
}
c <- struct{}{}
}()
<-c
for i := 0; i < 3; i++ {
go func() {
for i := 0; i < 5; i++ {
echo.run(nil, "", func(b []byte, err error) error {
return err
})
}
c <- struct{}{}
}()
}

for i := 0; i < 3; i++ {
<-c
}

p.wait()
}

0 comments on commit 5281740

Please sign in to comment.