Skip to content

Commit

Permalink
tests: Do not write test logs to summary
Browse files Browse the repository at this point in the history
Test logs can be quite large and overflow the max summary size.
Instead just log the test name in the summary (this is for slow tests).

Signed-off-by: Brian Goff <[email protected]>
  • Loading branch information
cpuguy83 committed Feb 4, 2025
1 parent aedd498 commit 6a3c4c2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions cmd/test2json2gha/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,15 @@ func do(in io.Reader, out io.Writer, modName string, slowThreshold time.Duration
}
}

if err := writeResult(tr, buf, failBuf, slowBuf, slow, modName); err != nil {
if err := writeResult(tr, buf, failBuf, modName); err != nil {
slog.Error("Error writing result", "error", err)
continue
}

if tr.elapsed > slow {
fmt.Fprintf(slowBuf, "%s %.3fs\n", tr.name, tr.elapsed)
}

if err := buf.Flush(); err != nil {
slog.Error(err.Error())
}
Expand Down Expand Up @@ -188,7 +192,7 @@ func getSummaryFile() io.WriteCloser {
return f
}

func writeResult(tr *TestResult, out, failBuf, slowBuf io.Writer, slow float64, modName string) error {
func writeResult(tr *TestResult, out, failBuf io.Writer, modName string) error {
if tr.name == "" {
return nil
}
Expand Down Expand Up @@ -219,16 +223,6 @@ func writeResult(tr *TestResult, out, failBuf, slowBuf io.Writer, slow float64,

var rdr io.Reader = tr.output

if tr.elapsed > slow {
buf := bytes.NewBuffer(nil)
rdr = io.TeeReader(rdr, buf)
defer func() {
if buf.Len() > 0 {
fmt.Fprintln(slowBuf, mdLog(fmt.Sprintf("%s %.3fs", tr.name, tr.elapsed), buf))
}
}()
}

if !tr.failed {
if _, err := io.Copy(out, rdr); err != nil {
return fmt.Errorf("error writing test output to output stream: %w", err)
Expand Down

0 comments on commit 6a3c4c2

Please sign in to comment.