Skip to content

Commit edc2cad

Browse files
authored
output stdout and stderr on example test failure (#11119)
1 parent 117d8d6 commit edc2cad

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

docs/examples/kubo-as-a-library/main_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import (
99
func TestExample(t *testing.T) {
1010
out, err := exec.Command("go", "run", "main.go").Output()
1111
if err != nil {
12-
t.Fatalf("running example (%v)", err)
12+
var stderr string
13+
if xe, ok := err.(*exec.ExitError); ok {
14+
stderr = string(xe.Stderr)
15+
}
16+
t.Fatalf("running example (%v): %s\n%s", err, string(out), stderr)
1317
}
1418
if !strings.Contains(string(out), "All done!") {
1519
t.Errorf("example did not run successfully")

0 commit comments

Comments
 (0)