From 4214b1746eb07be5a4a22dc0d26adada34e03679 Mon Sep 17 00:00:00 2001
From: curiousleo <curiousleo@ymail.com>
Date: Mon, 27 May 2019 21:20:54 +0200
Subject: [PATCH] Ensure Print{,f,ln} use global stdout

---
 cmd/restic/global_test.go | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 cmd/restic/global_test.go

diff --git a/cmd/restic/global_test.go b/cmd/restic/global_test.go
new file mode 100644
index 000000000..7d0477be6
--- /dev/null
+++ b/cmd/restic/global_test.go
@@ -0,0 +1,28 @@
+package main
+
+import (
+	"bytes"
+	"testing"
+
+	rtest "github.com/restic/restic/internal/test"
+)
+
+func Test_PrintFunctionsRespectsGlobalStdout(t *testing.T) {
+	gopts := globalOptions
+	defer func() {
+		globalOptions = gopts
+	}()
+
+	buf := bytes.NewBuffer(nil)
+	globalOptions.stdout = buf
+
+	for _, p := range []func(){
+		func() { Println("message") },
+		func() { Print("message\n") },
+		func() { Printf("mes%s\n", "sage") },
+	} {
+		p()
+		rtest.Equals(t, "message\n", buf.String())
+		buf.Reset()
+	}
+}