Skip to content

Commit

Permalink
Log stderr on test failure
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkroh committed Aug 3, 2022
1 parent a839fc0 commit 9b4bd49
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/gvm/use_test.go
Expand Up @@ -2,6 +2,7 @@ package main

import (
"bytes"
"errors"
"fmt"
"io"
"os"
Expand Down Expand Up @@ -73,7 +74,12 @@ func TestGVMRunUse(t *testing.T) {
// Test that GOROOT/bin/go exists and is the correct version.
version, err := exec.Command(filepath.Join(goroot, "bin", "go"), "version").Output()
if err != nil {
t.Fatal("failed to run go version", err)
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
t.Fatalf("failed to run go version: %v\n%s", err, exitErr.Stderr)
} else {
t.Fatal("failed to run go version", err)
}
}
assert.Contains(t, string(version), tc.Version)
})
Expand Down

0 comments on commit 9b4bd49

Please sign in to comment.