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

Dump mock log to stdout on failure #95

Merged
merged 1 commit into from
Jan 5, 2024
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
16 changes: 16 additions & 0 deletions impl/mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package impl
import (
"fmt"
"log"
"os"
"os/exec"
"path/filepath"
"strings"

Expand Down Expand Up @@ -171,6 +173,20 @@ func (bldr *mockBuilder) runMockCmd(extraArgs []string) error {
bldr.log("Running mock %s", strings.Join(mockArgs, " "))
mockErr := util.RunSystemCmd("mock", mockArgs...)
if mockErr != nil {
resultdir := getMockResultsDir(bldr.pkg, bldr.arch)
buildLogPath := filepath.Join(resultdir, "build.log")
if util.CheckPath(buildLogPath, false, false) == nil {
bldr.log("--- start of mock build.log ---")
dumpLogCmd := exec.Command("cat", buildLogPath)
dumpLogCmd.Stderr = os.Stderr
dumpLogCmd.Stdout = os.Stdout
if dumpLogCmd.Run() != nil {
bldr.log("Dumping logfile failed")
}
bldr.log("--- end of build.log ---")
} else {
bldr.log("No build.log found")
}
return fmt.Errorf("%smock %s errored out with %s",
bldr.errPrefix, strings.Join(mockArgs, " "), mockErr)
}
Expand Down