Commit | Line | Data |
---|---|---|
63cc4dd5 SM |
1 | From upstream PR: https://github.com/urfave/cli/pull/1299 |
2 | ||
3 | From: William Wilson <william.wilson@canonical.com> | |
4 | Date: Tue, 31 Aug 2021 14:19:17 -0500 | |
5 | Subject: Make test case compatible with Go 1.17 | |
6 | ||
7 | As of Go 1.17, the go flag package will panic if given a syntactically invalid | |
8 | flag. This causes TestApp_RunAsSubCommandIncorrectUsage to panic and therefore | |
9 | fail. See https://golang.org/doc/go1.17#flag for more information. | |
10 | ||
11 | --- | |
12 | diff --git a/app_test.go b/app_test.go | |
13 | index 7c38f6048..76e211d68 100644 | |
14 | --- a/app_test.go | |
15 | +++ b/app_test.go | |
16 | @@ -476,18 +476,18 @@ func TestApp_RunAsSubCommandIncorrectUsage(t *testing.T) { | |
17 | a := App{ | |
18 | Name: "cmd", | |
19 | Flags: []Flag{ | |
20 | - &StringFlag{Name: "--foo"}, | |
21 | + &StringFlag{Name: "foo"}, | |
22 | }, | |
23 | Writer: bytes.NewBufferString(""), | |
24 | } | |
25 | ||
26 | set := flag.NewFlagSet("", flag.ContinueOnError) | |
27 | - _ = set.Parse([]string{"", "---foo"}) | |
28 | + _ = set.Parse([]string{"", "-bar"}) | |
29 | c := &Context{flagSet: set} | |
30 | ||
31 | err := a.RunAsSubcommand(c) | |
32 | ||
33 | - expect(t, err, errors.New("bad flag syntax: ---foo")) | |
34 | + expect(t, err.Error(), "flag provided but not defined: -bar") | |
35 | } | |
36 | ||
37 | func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) { |