Package: golang-github-urfave-cli-v2
Version: 2.2.0-3
Severity: normal
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu impish ubuntu-patch

Dear Maintainer,

As of Go 1.17, the flag package panics if given a syntactically invalid flag.
This was causing build time tests of this package to fail and therefore
the package was not building in Ubuntu with Go 1.17.

In Ubuntu, the attached patch was applied to achieve the following:

Allow the package to build successfully with Go 1.17.

  * Change "incorrect usage" test case to use an undefined flag rather
    than a syntactically invalid flag. This prevents panics in test cases,
    as Go 1.17 panics with invalid flag syntax (LP: #1942255)


Thanks for considering the patch.


-- System Information:
Debian Release: bullseye/sid
  APT prefers hirsute-updates
  APT policy: (500, 'hirsute-updates'), (500, 'hirsute-security'), (500, 
'hirsute'), (100, 'hirsute-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 5.11.0-31-generic (SMP w/32 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru 
golang-github-urfave-cli-v2-2.2.0/debian/patches/0001-fix-failing-flag-test.patch
 
golang-github-urfave-cli-v2-2.2.0/debian/patches/0001-fix-failing-flag-test.patch
--- 
golang-github-urfave-cli-v2-2.2.0/debian/patches/0001-fix-failing-flag-test.patch
   1969-12-31 18:00:00.000000000 -0600
+++ 
golang-github-urfave-cli-v2-2.2.0/debian/patches/0001-fix-failing-flag-test.patch
   2021-08-31 13:54:29.000000000 -0500
@@ -0,0 +1,40 @@
+Description: Fix failing build time test
+ As of Go 1.17, the go flag package will panic if given a
+ syntactically invalid flag. This causes
+ TestApp_RunAsSubCommandIncorrectUsage to panic and therefore
+ fail. See https://golang.org/doc/go1.17#flag for more information.
+ This patch changes the test to use a flag that doesn't exist rather
+ than a syntactically invalid one to avoid the panic.
+Author: William 'jawn-smith' Wilson <william.wil...@canonical.com>
+Origin: Ubuntu
+Bug: https://github.com/urfave/cli/issues/1298
+Bug-Ubuntu: 
https://bugs.launchpad.net/ubuntu/+source/golang-github-urfave-cli-v2/+bug/1942255
+Forwarded: https://github.com/urfave/cli/pull/1299
+Applied-Upstream: <version|URL|commit, identifies patches merged upstream, 
optional>
+Last-Update: 2021-08-31
+---
+This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
+--- a/app_test.go
++++ b/app_test.go
+@@ -471,18 +471,18 @@
+       a := App{
+               Name: "cmd",
+               Flags: []Flag{
+-                      &StringFlag{Name: "--foo"},
++                      &StringFlag{Name: "foo"},
+               },
+               Writer: bytes.NewBufferString(""),
+       }
+ 
+       set := flag.NewFlagSet("", flag.ContinueOnError)
+-      _ = set.Parse([]string{"", "---foo"})
++      _ = set.Parse([]string{"", "-bar"})
+       c := &Context{flagSet: set}
+ 
+       err := a.RunAsSubcommand(c)
+ 
+-      expect(t, err, errors.New("bad flag syntax: ---foo"))
++      expect(t, err.Error(), "flag provided but not defined: -bar")
+ }
+ 
+ func TestApp_CommandWithFlagBeforeTerminator(t *testing.T) {
diff -Nru golang-github-urfave-cli-v2-2.2.0/debian/patches/series 
golang-github-urfave-cli-v2-2.2.0/debian/patches/series
--- golang-github-urfave-cli-v2-2.2.0/debian/patches/series     1969-12-31 
18:00:00.000000000 -0600
+++ golang-github-urfave-cli-v2-2.2.0/debian/patches/series     2021-08-31 
13:52:48.000000000 -0500
@@ -0,0 +1 @@
+0001-fix-failing-flag-test.patch

Reply via email to