Skip to content

Commit

Permalink
test: always wait for all goroutines
Browse files Browse the repository at this point in the history
  • Loading branch information
dennwc committed Sep 15, 2021
1 parent 4952273 commit a189309
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions translate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os/exec"
"path/filepath"
"strconv"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -333,10 +334,15 @@ func testTranspileOut(t testing.TB, csrc string) {
err = ioutil.WriteFile(cfile, []byte(csrc), 0644)
require.NoError(t, err)

// this is required for test to wait other goroutines in case it fails earlier on the main one
var wg sync.WaitGroup
wg.Add(1)
cch := make(chan progOut, 1)
go func() {
defer wg.Done()
cch <- gccCompileAndExec(t, cdir, cfile)
}()
defer wg.Wait()

godir := filepath.Join(dir, "golang")
err = os.MkdirAll(godir, 0755)
Expand Down

0 comments on commit a189309

Please sign in to comment.