Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies in v2-maint #1980

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 54 additions & 7 deletions fish_test.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package cli

import (
"bytes"
"context"
"os"
"os/exec"
"path/filepath"
"strings"
"testing"
"time"
)

func TestFishCompletion(t *testing.T) {
Expand Down Expand Up @@ -135,11 +139,54 @@ Should be a part of the same code block
return app
}

func expectFileContent(t *testing.T, file, got string) {
func expectFileContent(t *testing.T, file, expected string) {
data, err := os.ReadFile(file)
// Ignore windows line endings
// TODO: Replace with bytes.ReplaceAll when support for Go 1.11 is dropped
data = bytes.Replace(data, []byte("\r\n"), []byte("\n"), -1)
expect(t, err, nil)
expect(t, got, string(data))
if err != nil {
t.FailNow()
}

expected = strings.TrimSpace(expected)
actual := strings.TrimSpace(strings.ReplaceAll(string(data), "\r\n", "\n"))

if expected != actual {
t.Logf("file %q content does not match expected", file)

tryDiff(t, expected, actual)

t.FailNow()
}
}

func tryDiff(t *testing.T, a, b string) {
diff, err := exec.LookPath("diff")
if err != nil {
t.Logf("no diff tool available")

return
}

td := t.TempDir()
aPath := filepath.Join(td, "a")
bPath := filepath.Join(td, "b")

if err := os.WriteFile(aPath, []byte(a), 0o0644); err != nil {
t.Logf("failed to write: %v", err)
t.FailNow()

return
}

if err := os.WriteFile(bPath, []byte(b), 0o0644); err != nil {
t.Logf("failed to write: %v", err)
t.FailNow()
}

ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
t.Cleanup(cancel)

cmd := exec.CommandContext(ctx, diff, "-u", aPath, bPath)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr

_ = cmd.Run()
}
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ module github.com/urfave/cli/v2
go 1.18

require (
github.com/BurntSushi/toml v1.3.2
github.com/cpuguy83/go-md2man/v2 v2.0.4
github.com/BurntSushi/toml v1.4.0
github.com/cpuguy83/go-md2man/v2 v2.0.5
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1
gopkg.in/yaml.v3 v3.0.1
)
Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0=
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/xrash/smetrics v0.0.0-20240521201337-686a1a2994c1 h1:gEOO8jv9F4OT7lGCjxCBTO/36wtF6j2nSip77qHd4x4=
Expand Down
11 changes: 1 addition & 10 deletions testdata/expected-doc-full.man
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
.TH greet 8

.SH NAME
.PP
greet - Some app
greet \- Some app


.SH SYNOPSIS
.PP
greet

.EX
Expand All @@ -18,7 +16,6 @@ greet


.SH DESCRIPTION
.PP
Description of the application.

.PP
Expand All @@ -30,7 +27,6 @@ app [first_arg] [second_arg]


.SH GLOBAL OPTIONS
.PP
\fB--another-flag, -b\fP: another usage text

.PP
Expand All @@ -42,7 +38,6 @@ app [first_arg] [second_arg]

.SH COMMANDS
.SH config, c
.PP
another usage test

.PP
Expand All @@ -52,7 +47,6 @@ another usage test
\fB--flag, --fl, -f\fP="":

.SS sub-config, s, ss
.PP
another usage test

.PP
Expand All @@ -62,12 +56,10 @@ another usage test
\fB--sub-flag, --sub-fl, -s\fP="":

.SH info, i, in
.PP
retrieve generic information

.SH some-command
.SH usage, u
.PP
standard usage text

.EX
Expand All @@ -90,7 +82,6 @@ Should be a part of the same code block
\fB--flag, --fl, -f\fP="":

.SS sub-usage, su
.PP
standard usage text

.PP
Expand Down