From 2790b68253e8df395da60096bcea40e90daa3b41 Mon Sep 17 00:00:00 2001 From: spf13 Date: Fri, 27 Jun 2014 09:58:16 -0400 Subject: Fixing issues so test pass again --- flag.go | 2 +- flag_test.go | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/flag.go b/flag.go index 0af452d..9a16e7a 100644 --- a/flag.go +++ b/flag.go @@ -379,7 +379,7 @@ func (f *FlagSet) AddFlag(flag *Flag) { c := flag.Shorthand[0] old, alreadythere := f.shorthands[c] if alreadythere { - fmt.Fprintf(f.out(), "%s shorthand reused: %q for %s already used for %s\n", f.name, c, name, old.Name) + fmt.Fprintf(f.out(), "%s shorthand reused: %q for %s already used for %s\n", f.name, c, flag.Name, old.Name) panic("shorthand redefinition") } f.shorthands[c] = flag diff --git a/flag_test.go b/flag_test.go index aa8682f..4d95b15 100644 --- a/flag_test.go +++ b/flag_test.go @@ -7,13 +7,14 @@ package pflag_test import ( "bytes" "fmt" + "io/ioutil" "os" "sort" "strings" "testing" "time" - . "github.com/ogier/pflag" + . "github.com/spf13/pflag" ) var ( @@ -195,8 +196,9 @@ func TestShorthand(t *testing.T) { "--", notaflag, } - if err := f.Parse(args); err != nil { - t.Fatal(err) + f.SetOutput(ioutil.Discard) + if err := f.Parse(args); err == nil { + t.Error("--i-look-like-a-flag should throw an error") } if !f.Parsed() { t.Error("f.Parse() = false after Parse") -- cgit v1.2.3