From 7b94fd3aad1db29bdf260402c6edaa6e5488bfe7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Haugen?= Date: Sat, 28 Nov 2015 18:26:10 +0100 Subject: [PATCH] test: avoid output from "go test" when tests pass Some tests where printing to os.Stdout as a side effect even if the output was not used/checked in the test. --- app_test.go | 2 ++ command_test.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/app_test.go b/app_test.go index 28d8e0f..59fa75a 100644 --- a/app_test.go +++ b/app_test.go @@ -5,6 +5,7 @@ import ( "flag" "fmt" "io" + "io/ioutil" "os" "strings" "testing" @@ -556,6 +557,7 @@ func TestAppNoHelpFlag(t *testing.T) { HelpFlag = BoolFlag{} app := NewApp() + app.Writer = ioutil.Discard err := app.Run([]string{"test", "-h"}) if err != flag.ErrHelp { diff --git a/command_test.go b/command_test.go index dd9fc87..ac10652 100644 --- a/command_test.go +++ b/command_test.go @@ -3,6 +3,7 @@ package cli import ( "errors" "flag" + "io/ioutil" "testing" ) @@ -20,6 +21,7 @@ func TestCommandFlagParsing(t *testing.T) { for _, c := range cases { app := NewApp() + app.Writer = ioutil.Discard set := flag.NewFlagSet("test", 0) set.Parse(c.testArgs)