Skip to content

Commit

Permalink
fixed: wait for stderr pipe
Browse files Browse the repository at this point in the history
  • Loading branch information
strowk committed Dec 8, 2024
1 parent c685b64 commit 88b0500
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/foxytest/testsuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -525,11 +525,13 @@ func (ts *testSuite) startExecutable(t TestRunner) *exec.Cmd {
// and this only happens when using go test ./... , while not happening with simple go test
// So would instead send stderr to the test log output

stderrPipeCreated := make(chan struct{})
go func() {
errReader, err := cmd.StderrPipe()
if err != nil {
t.Fatalf("error creating stderr pipe: %v", err)
}
close(stderrPipeCreated)
scanner := bufio.NewScanner(errReader)
for scanner.Scan() {
t.Logf("stderr: %s", scanner.Text())
Expand All @@ -539,6 +541,8 @@ func (ts *testSuite) startExecutable(t TestRunner) *exec.Cmd {
}
}()

<-stderrPipeCreated

if ts.logging {
t.Logf("running command: %s %s", ts.command, strings.Join(ts.args, " "))
}
Expand Down

0 comments on commit 88b0500

Please sign in to comment.