@cryptotaxi247 / kubo / commits / edc2cadc8

output stdout and stderr on example test failure (#11119)

Andrew Gillis committed Dec 19, 2025 at 17:08 UTC edc2cadc85a17ba30c5c1fd5b48c7813bf953e56
1 file changed +5 -1
docs/examples/kubo-as-a-library/main_test.go
+5 -1
@@ -9,7 +9,11 @@ import (
9 func TestExample(t *testing.T) {
10 out, err := exec.Command("go", "run", "main.go").Output()
11 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)
17 }
18 if !strings.Contains(string(out), "All done!") {
19 t.Errorf("example did not run successfully")