Skip to content
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

Log all stdout in CI #1566

Merged
merged 1 commit into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
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
35 changes: 0 additions & 35 deletions eng/_util/buildutil/buildutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
package buildutil

import (
"bufio"
"encoding/json"
"fmt"
"io"
"log"
Expand Down Expand Up @@ -125,39 +123,6 @@ func UnassignGOROOT() error {
return nil
}

// NewStripTestJSONWriter strips all individual test results and output entries from a JSON stream.
// Only the overall package test results are written to the underlying writer.
func NewStripTestJSONWriter(w io.Writer) io.Writer {
pr, pw := io.Pipe()
go func() {
type test struct {
Action string
Package string
Test string
}
sc := bufio.NewScanner(pr)
for sc.Scan() {
var t test
err := json.Unmarshal(sc.Bytes(), &t)
if err == nil && (t.Test != "" || t.Action == "output") {
// Omit the test result.
continue
}
_, err = w.Write(append(sc.Bytes(), '\n'))
if err != nil {
pw.CloseWithError(err)
return
}
}
if err := sc.Err(); err != nil {
pw.CloseWithError(err)
return
}
pw.Close()
}()
return pw
}

// RunCmdMultiWriter runs a command and outputs the stdout to multiple [io.Writer].
// The writers are closed after the command completes.
func RunCmdMultiWriter(cmdline []string, stdout ...io.Writer) (err error) {
Expand Down
2 changes: 1 addition & 1 deletion eng/_util/cmd/build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func build(o *options) (err error) {
err = closeErr
}
}()
if err := buildutil.RunCmdMultiWriter(testCommandLine, conv, buildutil.NewStripTestJSONWriter(os.Stdout)); err != nil {
if err := buildutil.RunCmdMultiWriter(testCommandLine, conv, os.Stdout); err != nil {
return err
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion eng/_util/cmd/run-builder/run-builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func main() {
log.Fatal(err)
}
}()
err = buildutil.RunCmdMultiWriter(cmdline, conv, buildutil.NewStripTestJSONWriter(os.Stdout))
err = buildutil.RunCmdMultiWriter(cmdline, conv, os.Stdout)
// If we got an ExitError, the error message was already printed by the command. We just
// need to exit with the same exit code.
if exitErr, ok := err.(*exec.ExitError); ok {
Expand Down