diff options
Diffstat (limited to 'hugolib/testhelpers_test.go')
-rw-r--r-- | hugolib/testhelpers_test.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/hugolib/testhelpers_test.go b/hugolib/testhelpers_test.go index eace35c97..c1ee27557 100644 --- a/hugolib/testhelpers_test.go +++ b/hugolib/testhelpers_test.go @@ -1070,3 +1070,18 @@ func captureStderr(f func() error) (string, error) { io.Copy(&buf, r) return buf.String(), err } + +func captureStdout(f func() error) (string, error) { + old := os.Stdout + r, w, _ := os.Pipe() + os.Stdout = w + + err := f() + + w.Close() + os.Stdout = old + + var buf bytes.Buffer + io.Copy(&buf, r) + return buf.String(), err +} |