Skip to content

Commit 3bb6f21

Browse files
authored
e2e: include cmd output in error messages (#1505)
1 parent 7987ea1 commit 3bb6f21

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

e2e/e2e.go

+7-8
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ func (t *E2ETester) Start() (*E2EResult, error) {
7070
log.Printf("checking out branch %q", branchName)
7171
checkoutCmd := exec.Command("git", "checkout", "-b", branchName)
7272
checkoutCmd.Dir = cloneDir
73-
if err := checkoutCmd.Run(); err != nil {
74-
return e2eResult, fmt.Errorf("failed to git checkout branch %q: %v", branchName, err)
73+
if output, err := checkoutCmd.CombinedOutput(); err != nil {
74+
return e2eResult, fmt.Errorf("failed to git checkout branch %q: %v: %s", branchName, err, string(output))
7575
}
7676

7777
// write a file for running the tests
@@ -87,25 +87,24 @@ func (t *E2ETester) Start() (*E2EResult, error) {
8787
log.Printf("git add file %q", filePath)
8888
addCmd := exec.Command("git", "add", filePath)
8989
addCmd.Dir = cloneDir
90-
if err = addCmd.Run(); err != nil {
91-
return e2eResult, fmt.Errorf("failed to git add file %q: %v", filePath, err)
90+
if output, err := addCmd.CombinedOutput(); err != nil {
91+
return e2eResult, fmt.Errorf("failed to git add file %q: %v: %s", filePath, err, string(output))
9292
}
9393

9494
// commit the file
9595
log.Printf("git commit file %q", filePath)
9696
commitCmd := exec.Command("git", "commit", "-am", "test commit")
9797
commitCmd.Dir = cloneDir
98-
var output []byte
99-
if output, err = commitCmd.CombinedOutput(); err != nil {
98+
if output, err := commitCmd.CombinedOutput(); err != nil {
10099
return e2eResult, fmt.Errorf("failed to run git commit in %q: %v: %v", cloneDir, err, string(output))
101100
}
102101

103102
// push the branch to remote
104103
log.Printf("git push branch %q", branchName)
105104
pushCmd := exec.Command("git", "push", "origin", branchName)
106105
pushCmd.Dir = cloneDir
107-
if err = pushCmd.Run(); err != nil {
108-
return e2eResult, fmt.Errorf("failed to git push branch %q: %v", branchName, err)
106+
if output, err := pushCmd.CombinedOutput(); err != nil {
107+
return e2eResult, fmt.Errorf("failed to git push branch %q: %v: %s", branchName, err, string(output))
109108
}
110109

111110
// create a new pr

0 commit comments

Comments
 (0)