Skip to content

Show compilation errors #3866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 24, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions hack/tests/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"
"encoding/json"
"fmt"
"io"
"os"
"os/exec"
"sort"
Expand All @@ -47,10 +48,10 @@ func goTest(testArgs []string) error {
verbose := isVerbose(testArgs)

cmd := exec.CommandContext(context.Background(), "go", args...)
out, err := cmd.StdoutPipe()
if err != nil {
return err
}

pr, pw := io.Pipe()
cmd.Stderr = pw
cmd.Stdout = pw

failedTests := map[string]bool{}
var failedLogs []LogLine
Expand All @@ -63,7 +64,7 @@ func goTest(testArgs []string) error {
defer wc.Done()

// Print logs while tests are running
scanner := bufio.NewScanner(out)
scanner := bufio.NewScanner(pr)
for i := 0; scanner.Scan(); i++ {
line := scanner.Bytes()

Expand Down Expand Up @@ -116,8 +117,12 @@ func goTest(testArgs []string) error {
}
}()

err = cmd.Run()
wc.Wait()
err := cmd.Run()
if err != nil {
pr.CloseWithError(err)
} else {
pr.Close()
}
return err
}

Expand Down