Skip to content

Commit 7a2ea5c

Browse files
committed
vendor: gotest.tools/v3 v3.5.1
full diff: https://github.com/gotestyourself/gotest.tools/compare/v3.5.0..v3.5.1 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 4d6cf13 commit 7a2ea5c

10 files changed

Lines changed: 65 additions & 37 deletions

File tree

vendor.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ require (
4343
golang.org/x/term v0.13.0
4444
golang.org/x/text v0.13.0
4545
gopkg.in/yaml.v2 v2.4.0
46-
gotest.tools/v3 v3.5.0
46+
gotest.tools/v3 v3.5.1
4747
)
4848

4949
require (

vendor.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,6 @@ gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C
386386
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
387387
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
388388
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
389-
gotest.tools/v3 v3.5.0 h1:Ljk6PdHdOhAb5aDMWXjDLMMhph+BpztA4v1QdqEW2eY=
390-
gotest.tools/v3 v3.5.0/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
389+
gotest.tools/v3 v3.5.1 h1:EENdUnS3pdur5nybKYIh2Vfgc8IUNBjxDPSjtiJcOzU=
390+
gotest.tools/v3 v3.5.1/go.mod h1:isy3WKz7GK6uNw/sbHzfKBLvlvXwUyV06n6brMxxopU=
391391
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=

vendor/gotest.tools/v3/fs/manifest.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ type dirEntry interface {
5555
Type() string
5656
}
5757

58-
// ManifestFromDir creates a Manifest by reading the directory at path. The
58+
// ManifestFromDir creates a [Manifest] by reading the directory at path. The
5959
// manifest stores the structure and properties of files in the directory.
60-
// ManifestFromDir can be used with Equal to compare two directories.
60+
// ManifestFromDir can be used with [Equal] to compare two directories.
6161
func ManifestFromDir(t assert.TestingT, path string) Manifest {
6262
if ht, ok := t.(helperT); ok {
6363
ht.Helper()

vendor/gotest.tools/v3/fs/ops.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import (
1414

1515
const defaultFileMode = 0644
1616

17-
// PathOp is a function which accepts a Path and performs an operation on that
18-
// path. When called with real filesystem objects (File or Dir) a PathOp modifies
19-
// the filesystem at the path. When used with a Manifest object a PathOp updates
17+
// PathOp is a function which accepts a [Path] and performs an operation on that
18+
// path. When called with real filesystem objects ([File] or [Dir]) a PathOp modifies
19+
// the filesystem at the path. When used with a [Manifest] object a PathOp updates
2020
// the manifest to expect a value.
2121
type PathOp func(path Path) error
2222

@@ -38,7 +38,7 @@ type manifestDirectory interface {
3838
AddDirectory(path string, ops ...PathOp) error
3939
}
4040

41-
// WithContent writes content to a file at Path
41+
// WithContent writes content to a file at [Path]
4242
func WithContent(content string) PathOp {
4343
return func(path Path) error {
4444
if m, ok := path.(manifestFile); ok {
@@ -49,7 +49,7 @@ func WithContent(content string) PathOp {
4949
}
5050
}
5151

52-
// WithBytes write bytes to a file at Path
52+
// WithBytes write bytes to a file at [Path]
5353
func WithBytes(raw []byte) PathOp {
5454
return func(path Path) error {
5555
if m, ok := path.(manifestFile); ok {
@@ -60,7 +60,7 @@ func WithBytes(raw []byte) PathOp {
6060
}
6161
}
6262

63-
// WithReaderContent copies the reader contents to the file at Path
63+
// WithReaderContent copies the reader contents to the file at [Path]
6464
func WithReaderContent(r io.Reader) PathOp {
6565
return func(path Path) error {
6666
if m, ok := path.(manifestFile); ok {
@@ -77,7 +77,7 @@ func WithReaderContent(r io.Reader) PathOp {
7777
}
7878
}
7979

80-
// AsUser changes ownership of the file system object at Path
80+
// AsUser changes ownership of the file system object at [Path]
8181
func AsUser(uid, gid int) PathOp {
8282
return func(path Path) error {
8383
if m, ok := path.(manifestResource); ok {
@@ -132,7 +132,7 @@ func WithFiles(files map[string]string) PathOp {
132132
}
133133
}
134134

135-
// FromDir copies the directory tree from the source path into the new Dir
135+
// FromDir copies the directory tree from the source path into the new [Dir]
136136
func FromDir(source string) PathOp {
137137
return func(path Path) error {
138138
if _, ok := path.(manifestDirectory); ok {
@@ -142,7 +142,7 @@ func FromDir(source string) PathOp {
142142
}
143143
}
144144

145-
// WithDir creates a subdirectory in the directory at path. Additional PathOp
145+
// WithDir creates a subdirectory in the directory at path. Additional [PathOp]
146146
// can be used to modify the subdirectory
147147
func WithDir(name string, ops ...PathOp) PathOp {
148148
const defaultMode = 0755
@@ -161,7 +161,7 @@ func WithDir(name string, ops ...PathOp) PathOp {
161161
}
162162
}
163163

164-
// Apply the PathOps to the File
164+
// Apply the PathOps to the [File]
165165
func Apply(t assert.TestingT, path Path, ops ...PathOp) {
166166
if ht, ok := t.(helperT); ok {
167167
ht.Helper()
@@ -178,7 +178,7 @@ func applyPathOps(path Path, ops []PathOp) error {
178178
return nil
179179
}
180180

181-
// WithMode sets the file mode on the directory or file at path
181+
// WithMode sets the file mode on the directory or file at [Path]
182182
func WithMode(mode os.FileMode) PathOp {
183183
return func(path Path) error {
184184
if m, ok := path.(manifestResource); ok {
@@ -241,7 +241,7 @@ func copyFile(source, dest string) error {
241241
// WithSymlink creates a symlink in the directory which links to target.
242242
// Target must be a path relative to the directory.
243243
//
244-
// Note: the argument order is the inverse of os.Symlink to be consistent with
244+
// Note: the argument order is the inverse of [os.Symlink] to be consistent with
245245
// the other functions in this package.
246246
func WithSymlink(path, target string) PathOp {
247247
return func(root Path) error {
@@ -255,7 +255,7 @@ func WithSymlink(path, target string) PathOp {
255255
// WithHardlink creates a link in the directory which links to target.
256256
// Target must be a path relative to the directory.
257257
//
258-
// Note: the argument order is the inverse of os.Link to be consistent with
258+
// Note: the argument order is the inverse of [os.Link] to be consistent with
259259
// the other functions in this package.
260260
func WithHardlink(path, target string) PathOp {
261261
return func(root Path) error {

vendor/gotest.tools/v3/fs/path.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ func (p *directoryPath) AddDirectory(path string, ops ...PathOp) error {
7777
return applyPathOps(exp, ops)
7878
}
7979

80-
// Expected returns a Manifest with a directory structured created by ops. The
81-
// PathOp operations are applied to the manifest as expectations of the
80+
// Expected returns a [Manifest] with a directory structured created by ops. The
81+
// [PathOp] operations are applied to the manifest as expectations of the
8282
// filesystem structure and properties.
8383
func Expected(t assert.TestingT, ops ...PathOp) Manifest {
8484
if ht, ok := t.(helperT); ok {
@@ -125,7 +125,7 @@ func normalizeID(id int) uint32 {
125125

126126
var anyFileContent = io.NopCloser(bytes.NewReader(nil))
127127

128-
// MatchAnyFileContent is a PathOp that updates a Manifest so that the file
128+
// MatchAnyFileContent is a [PathOp] that updates a [Manifest] so that the file
129129
// at path may contain any content.
130130
func MatchAnyFileContent(path Path) error {
131131
if m, ok := path.(*filePath); ok {
@@ -134,7 +134,7 @@ func MatchAnyFileContent(path Path) error {
134134
return nil
135135
}
136136

137-
// MatchContentIgnoreCarriageReturn is a PathOp that ignores cariage return
137+
// MatchContentIgnoreCarriageReturn is a [PathOp] that ignores cariage return
138138
// discrepancies.
139139
func MatchContentIgnoreCarriageReturn(path Path) error {
140140
if m, ok := path.(*filePath); ok {
@@ -145,7 +145,7 @@ func MatchContentIgnoreCarriageReturn(path Path) error {
145145

146146
const anyFile = "*"
147147

148-
// MatchExtraFiles is a PathOp that updates a Manifest to allow a directory
148+
// MatchExtraFiles is a [PathOp] that updates a [Manifest] to allow a directory
149149
// to contain unspecified files.
150150
func MatchExtraFiles(path Path) error {
151151
if m, ok := path.(*directoryPath); ok {
@@ -156,14 +156,14 @@ func MatchExtraFiles(path Path) error {
156156

157157
// CompareResult is the result of comparison.
158158
//
159-
// See gotest.tools/assert/cmp.StringResult for a convenient implementation of
159+
// See [gotest.tools/v3/assert/cmp.StringResult] for a convenient implementation of
160160
// this interface.
161161
type CompareResult interface {
162162
Success() bool
163163
FailureMessage() string
164164
}
165165

166-
// MatchFileContent is a PathOp that updates a Manifest to use the provided
166+
// MatchFileContent is a [PathOp] that updates a [Manifest] to use the provided
167167
// function to determine if a file's content matches the expectation.
168168
func MatchFileContent(f func([]byte) CompareResult) PathOp {
169169
return func(path Path) error {
@@ -174,7 +174,7 @@ func MatchFileContent(f func([]byte) CompareResult) PathOp {
174174
}
175175
}
176176

177-
// MatchFilesWithGlob is a PathOp that updates a Manifest to match files using
177+
// MatchFilesWithGlob is a [PathOp] that updates a [Manifest] to match files using
178178
// glob pattern, and check them using the ops.
179179
func MatchFilesWithGlob(glob string, ops ...PathOp) PathOp {
180180
return func(path Path) error {
@@ -188,7 +188,7 @@ func MatchFilesWithGlob(glob string, ops ...PathOp) PathOp {
188188
// anyFileMode is represented by uint32_max
189189
const anyFileMode os.FileMode = 4294967295
190190

191-
// MatchAnyFileMode is a PathOp that updates a Manifest so that the resource at path
191+
// MatchAnyFileMode is a [PathOp] that updates a [Manifest] so that the resource at path
192192
// will match any file mode.
193193
func MatchAnyFileMode(path Path) error {
194194
if m, ok := path.(manifestResource); ok {

vendor/gotest.tools/v3/fs/report.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ import (
1717
// Equal compares a directory to the expected structured described by a manifest
1818
// and returns success if they match. If they do not match the failure message
1919
// will contain all the differences between the directory structure and the
20-
// expected structure defined by the Manifest.
20+
// expected structure defined by the [Manifest].
2121
//
22-
// Equal is a cmp.Comparison which can be used with assert.Assert().
22+
// Equal is a [cmp.Comparison] which can be used with [gotest.tools/v3/assert.Assert].
2323
func Equal(path string, expected Manifest) cmp.Comparison {
2424
return func() cmp.Result {
2525
actual, err := manifestFromDir(path)

vendor/gotest.tools/v3/golden/golden.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Golden files can be automatically updated to match new values by running
66
`go test pkgname -update`. To ensure the update is correct
77
compare the diff of the old expected value to the new expected value.
88
*/
9-
package golden // import "gotest.tools/v3/golden"
9+
package golden
1010

1111
import (
1212
"bytes"
@@ -40,11 +40,19 @@ type helperT interface {
4040
// in the environment before running tests.
4141
//
4242
// The default value may change in a future major release.
43+
//
44+
// This does not affect the contents of the golden files themselves. And depending on the
45+
// git settings on your system (or in github action platform default like windows), the
46+
// golden files may contain CRLF line endings. You can avoid this by setting the
47+
// .gitattributes file in your repo to use LF line endings for all files, or just the golden
48+
// files, by adding the following line to your .gitattributes file:
49+
//
50+
// * text=auto eol=lf
4351
var NormalizeCRLFToLF = os.Getenv("GOTESTTOOLS_GOLDEN_NormalizeCRLFToLF") != "false"
4452

4553
// FlagUpdate returns true when the -update flag has been set.
4654
func FlagUpdate() bool {
47-
return source.Update
55+
return source.IsUpdate()
4856
}
4957

5058
// Open opens the file in ./testdata
@@ -178,7 +186,7 @@ func compare(actual []byte, filename string) (cmp.Result, []byte) {
178186
}
179187

180188
func update(filename string, actual []byte) error {
181-
if !source.Update {
189+
if !source.IsUpdate() {
182190
return nil
183191
}
184192
if dir := filepath.Dir(Path(filename)); dir != "." {

vendor/gotest.tools/v3/internal/assert/result.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func RunComparison(
2626
return true
2727
}
2828

29-
if source.Update {
29+
if source.IsUpdate() {
3030
if updater, ok := result.(updateExpected); ok {
3131
const stackIndex = 3 // Assert/Check, assert, RunComparison
3232
err := updater.UpdatedExpected(stackIndex)

vendor/gotest.tools/v3/internal/source/update.go

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,32 @@ import (
1414
"strings"
1515
)
1616

17-
// Update is set by the -update flag. It indicates the user running the tests
18-
// would like to update any golden values.
17+
// IsUpdate is returns true if the -update flag is set. It indicates the user
18+
// running the tests would like to update any golden values.
19+
func IsUpdate() bool {
20+
if Update {
21+
return true
22+
}
23+
return flag.Lookup("update").Value.(flag.Getter).Get().(bool)
24+
}
25+
26+
// Update is a shim for testing, and for compatibility with the old -update-golden
27+
// flag.
1928
var Update bool
2029

2130
func init() {
22-
flag.BoolVar(&Update, "update", false, "update golden values")
31+
if f := flag.Lookup("update"); f != nil {
32+
getter, ok := f.Value.(flag.Getter)
33+
msg := "some other package defined an incompatible -update flag, expected a flag.Bool"
34+
if !ok {
35+
panic(msg)
36+
}
37+
if _, ok := getter.Get().(bool); !ok {
38+
panic(msg)
39+
}
40+
return
41+
}
42+
flag.Bool("update", false, "update golden values")
2343
}
2444

2545
// ErrNotFound indicates that UpdateExpectedValue failed to find the

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ google.golang.org/protobuf/types/known/timestamppb
460460
# gopkg.in/yaml.v2 v2.4.0
461461
## explicit; go 1.15
462462
gopkg.in/yaml.v2
463-
# gotest.tools/v3 v3.5.0
463+
# gotest.tools/v3 v3.5.1
464464
## explicit; go 1.17
465465
gotest.tools/v3/assert
466466
gotest.tools/v3/assert/cmp

0 commit comments

Comments
 (0)