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

fix: test2json: detect test timeouts and other package-level errors #482

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- name: download deps
run: go mod download
- name: Run integration tests
run: go test -v -json ./test | go run ./cmd/test2json2gha
run: go test -v -timeout=30m -json ./test | go run ./cmd/test2json2gha
- name: dump logs
if: failure()
run: sudo journalctl -u docker
Expand Down
9 changes: 6 additions & 3 deletions cmd/test2json2gha/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func do(in io.Reader, out io.Writer, modName string) (bool, error) {
return tr, nil
}

var anyFail bool
for {
*te = TestEvent{}
if err := dec.Decode(te); err != nil {
Expand All @@ -115,20 +116,22 @@ func do(in io.Reader, out io.Writer, modName string) (bool, error) {
if te.Test == "" {
// Don't bother processing events that aren't specifically for a test
// Go adds extra events in for package level info that we don't need.
if te.Action == "fail" {
anyFail = true
}
continue
}

tr, err := getOutputStream()
if err != nil {
return false, err
}
if err := handlEvent(te, tr); err != nil {
if err := handleEvent(te, tr); err != nil {
slog.Error("Error handing event test event", "error", err)
}
}

buf := bufio.NewWriter(out)
var anyFail bool

for _, tr := range outs {
if tr.failed {
Expand All @@ -148,7 +151,7 @@ func do(in io.Reader, out io.Writer, modName string) (bool, error) {
return anyFail, nil
}

func handlEvent(te *TestEvent, tr *TestResult) error {
func handleEvent(te *TestEvent, tr *TestResult) error {
if te.Output != "" {
_, err := tr.output.Write([]byte(te.Output))
if err != nil {
Expand Down
Loading