diff --git a/cio/io_test.go b/cio/io_test.go index e42836f76..1ca951c16 100644 --- a/cio/io_test.go +++ b/cio/io_test.go @@ -33,8 +33,8 @@ import ( "github.com/containerd/fifo" "github.com/google/go-cmp/cmp/cmpopts" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) func assertHasPrefix(t *testing.T, s, prefix string) { diff --git a/cio/io_unix_test.go b/cio/io_unix_test.go index fc2cce96d..58412d71f 100644 --- a/cio/io_unix_test.go +++ b/cio/io_unix_test.go @@ -23,7 +23,7 @@ import ( "path/filepath" "testing" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) func TestOpenFifos(t *testing.T) { diff --git a/cio/io_windows_test.go b/cio/io_windows_test.go index e0191480e..92fa1ff1c 100644 --- a/cio/io_windows_test.go +++ b/cio/io_windows_test.go @@ -21,7 +21,7 @@ package cio import ( "testing" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) func TestNewFifoSetInDir_NoTerminal(t *testing.T) { diff --git a/client_ttrpc_test.go b/client_ttrpc_test.go index b12da5f27..85b7aa383 100644 --- a/client_ttrpc_test.go +++ b/client_ttrpc_test.go @@ -26,7 +26,7 @@ import ( "github.com/containerd/containerd/pkg/ttrpcutil" "github.com/containerd/ttrpc" "github.com/gogo/protobuf/types" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) func TestClientTTRPC_New(t *testing.T) { diff --git a/content/helpers_test.go b/content/helpers_test.go index 95079a9a6..1b4e39926 100644 --- a/content/helpers_test.go +++ b/content/helpers_test.go @@ -26,8 +26,8 @@ import ( "github.com/containerd/containerd/errdefs" "github.com/opencontainers/go-digest" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) type copySource struct { diff --git a/content/local/store_test.go b/content/local/store_test.go index 86e284a77..559bdab99 100644 --- a/content/local/store_test.go +++ b/content/local/store_test.go @@ -40,7 +40,7 @@ import ( "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) type memoryLabelStore struct { diff --git a/content/testsuite/testsuite.go b/content/testsuite/testsuite.go index 3e1a90ddf..8264f6274 100644 --- a/content/testsuite/testsuite.go +++ b/content/testsuite/testsuite.go @@ -36,7 +36,7 @@ import ( digest "github.com/opencontainers/go-digest" ocispec "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) const ( diff --git a/gc/scheduler/scheduler_test.go b/gc/scheduler/scheduler_test.go index 8027d993a..3690b78db 100644 --- a/gc/scheduler/scheduler_test.go +++ b/gc/scheduler/scheduler_test.go @@ -23,7 +23,7 @@ import ( "time" "github.com/containerd/containerd/gc" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) func TestPauseThreshold(t *testing.T) { diff --git a/log/context_test.go b/log/context_test.go index c5da476fa..0d9827c6d 100644 --- a/log/context_test.go +++ b/log/context_test.go @@ -20,7 +20,7 @@ import ( "context" "testing" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) func TestLoggerContext(t *testing.T) { diff --git a/mount/lookup_linux_test.go b/mount/lookup_linux_test.go index e9347566e..f2ca5fd43 100644 --- a/mount/lookup_linux_test.go +++ b/mount/lookup_linux_test.go @@ -31,7 +31,7 @@ import ( // so we use continuity/testutil instead. "github.com/containerd/continuity/testutil" "github.com/containerd/continuity/testutil/loopback" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) func checkLookup(t *testing.T, fsType, mntPoint, dir string) { diff --git a/pkg/testutil/helpers_unix.go b/pkg/testutil/helpers_unix.go index 96dd92eac..eee004af8 100644 --- a/pkg/testutil/helpers_unix.go +++ b/pkg/testutil/helpers_unix.go @@ -24,7 +24,7 @@ import ( "testing" "github.com/containerd/containerd/mount" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) // Unmount unmounts a given mountPoint and sets t.Error if it fails diff --git a/remotes/docker/fetcher_test.go b/remotes/docker/fetcher_test.go index 92a308378..5930ec614 100644 --- a/remotes/docker/fetcher_test.go +++ b/remotes/docker/fetcher_test.go @@ -29,7 +29,7 @@ import ( "testing" "github.com/pkg/errors" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) func TestFetcherOpen(t *testing.T) { diff --git a/remotes/docker/scope_test.go b/remotes/docker/scope_test.go index 2ec0feebd..e9995a6a4 100644 --- a/remotes/docker/scope_test.go +++ b/remotes/docker/scope_test.go @@ -21,8 +21,8 @@ import ( "testing" "github.com/containerd/containerd/reference" - "gotest.tools/assert" - "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + "gotest.tools/v3/assert/cmp" ) func TestRepositoryScope(t *testing.T) { diff --git a/services/server/config/config_test.go b/services/server/config/config_test.go index 3091abc5d..47a12f17b 100644 --- a/services/server/config/config_test.go +++ b/services/server/config/config_test.go @@ -23,7 +23,7 @@ import ( "sort" "testing" - "gotest.tools/assert" + "gotest.tools/v3/assert" "github.com/containerd/containerd/plugin" ) diff --git a/services/server/server_test.go b/services/server/server_test.go index 8a3b6b88c..a7b1a144f 100644 --- a/services/server/server_test.go +++ b/services/server/server_test.go @@ -20,8 +20,8 @@ import ( "testing" srvconfig "github.com/containerd/containerd/services/server/config" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) func TestCreateTopLevelDirectoriesErrorsWithSamePathForRootAndState(t *testing.T) { diff --git a/snapshots/benchsuite/benchmark_test.go b/snapshots/benchsuite/benchmark_test.go index 05e3a183a..40514d54d 100644 --- a/snapshots/benchsuite/benchmark_test.go +++ b/snapshots/benchsuite/benchmark_test.go @@ -32,7 +32,7 @@ import ( "github.com/containerd/continuity/fs/fstest" "github.com/pkg/errors" "github.com/sirupsen/logrus" - "gotest.tools/assert" + "gotest.tools/v3/assert" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/snapshots" diff --git a/snapshots/devmapper/config_test.go b/snapshots/devmapper/config_test.go index b6b9cde2f..bae0ed616 100644 --- a/snapshots/devmapper/config_test.go +++ b/snapshots/devmapper/config_test.go @@ -25,8 +25,8 @@ import ( "github.com/BurntSushi/toml" "github.com/hashicorp/go-multierror" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) func TestLoadConfig(t *testing.T) { diff --git a/snapshots/devmapper/dmsetup/dmsetup_test.go b/snapshots/devmapper/dmsetup/dmsetup_test.go index 97fdeb9b1..3b4c688bb 100644 --- a/snapshots/devmapper/dmsetup/dmsetup_test.go +++ b/snapshots/devmapper/dmsetup/dmsetup_test.go @@ -26,8 +26,8 @@ import ( "github.com/docker/go-units" "golang.org/x/sys/unix" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" "github.com/containerd/containerd/pkg/testutil" "github.com/containerd/containerd/snapshots/devmapper/losetup" diff --git a/snapshots/devmapper/losetup/losetup_test.go b/snapshots/devmapper/losetup/losetup_test.go index 773ee59ca..b6d2d5ebc 100644 --- a/snapshots/devmapper/losetup/losetup_test.go +++ b/snapshots/devmapper/losetup/losetup_test.go @@ -25,8 +25,8 @@ import ( "github.com/docker/go-units" "golang.org/x/sys/unix" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" "github.com/containerd/containerd/pkg/testutil" ) diff --git a/snapshots/devmapper/metadata_test.go b/snapshots/devmapper/metadata_test.go index fe62d206c..1b475c7d5 100644 --- a/snapshots/devmapper/metadata_test.go +++ b/snapshots/devmapper/metadata_test.go @@ -28,8 +28,8 @@ import ( "github.com/pkg/errors" "go.etcd.io/bbolt" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) var ( diff --git a/snapshots/devmapper/pool_device_test.go b/snapshots/devmapper/pool_device_test.go index 49eef4089..7ee7301ef 100644 --- a/snapshots/devmapper/pool_device_test.go +++ b/snapshots/devmapper/pool_device_test.go @@ -34,7 +34,7 @@ import ( "github.com/containerd/containerd/snapshots/devmapper/losetup" "github.com/docker/go-units" "github.com/sirupsen/logrus" - "gotest.tools/assert" + "gotest.tools/v3/assert" ) const ( diff --git a/snapshots/devmapper/snapshotter_test.go b/snapshots/devmapper/snapshotter_test.go index 1ecde0528..5157be869 100644 --- a/snapshots/devmapper/snapshotter_test.go +++ b/snapshots/devmapper/snapshotter_test.go @@ -30,7 +30,7 @@ import ( "github.com/containerd/continuity/fs/fstest" "github.com/hashicorp/go-multierror" "github.com/sirupsen/logrus" - "gotest.tools/assert" + "gotest.tools/v3/assert" "github.com/containerd/containerd/mount" "github.com/containerd/containerd/namespaces" diff --git a/snapshots/storage/metastore_test.go b/snapshots/storage/metastore_test.go index a2b7e4ca6..90ed2ae73 100644 --- a/snapshots/storage/metastore_test.go +++ b/snapshots/storage/metastore_test.go @@ -28,8 +28,8 @@ import ( "github.com/containerd/containerd/snapshots" "github.com/google/go-cmp/cmp" "github.com/pkg/errors" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) type testFunc func(context.Context, *testing.T, *MetaStore) diff --git a/snapshots/testsuite/testsuite.go b/snapshots/testsuite/testsuite.go index c5af695f0..b2434025f 100644 --- a/snapshots/testsuite/testsuite.go +++ b/snapshots/testsuite/testsuite.go @@ -34,8 +34,8 @@ import ( "github.com/containerd/containerd/pkg/testutil" "github.com/containerd/containerd/snapshots" "github.com/containerd/continuity/fs/fstest" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) // SnapshotterFunc is used in SnapshotterSuite diff --git a/sys/oom_unix_test.go b/sys/oom_unix_test.go index f849c64ec..dee5f81bf 100644 --- a/sys/oom_unix_test.go +++ b/sys/oom_unix_test.go @@ -25,8 +25,8 @@ import ( "testing" "time" - "gotest.tools/assert" - is "gotest.tools/assert/cmp" + "gotest.tools/v3/assert" + is "gotest.tools/v3/assert/cmp" ) func TestSetPositiveOomScoreAdjustment(t *testing.T) { diff --git a/vendor.conf b/vendor.conf index 5478e850d..162bc8ba6 100644 --- a/vendor.conf +++ b/vendor.conf @@ -50,7 +50,7 @@ golang.org/x/sys c990c680b611ac1aeb7d8f2af94a golang.org/x/text 19e51611da83d6be54ddafce4a4af510cb3e9ea4 google.golang.org/genproto e50cd9704f63023d62cd06a1994b98227fc4d21a google.golang.org/grpc f495f5b15ae7ccda3b38c53a1bfcde4c1a58a2bc # v1.27.1 -gotest.tools 1083505acf35a0bd8a696b26837e1fb3187a7a83 # v2.3.0 +gotest.tools/v3 bb0d8a963040ea5048dcef1a14d8f8b58a33d4b3 # v3.0.2 # cri dependencies github.com/containerd/cri c0294ebfe0b4342db85c0faf7727ceb8d8c3afce # master diff --git a/vendor/gotest.tools/go.mod b/vendor/gotest.tools/go.mod deleted file mode 100644 index 39d0a1a77..000000000 --- a/vendor/gotest.tools/go.mod +++ /dev/null @@ -1,8 +0,0 @@ -module gotest.tools - -require ( - github.com/google/go-cmp v0.2.0 - github.com/pkg/errors v0.8.0 - github.com/spf13/pflag v1.0.3 - golang.org/x/tools v0.0.0-20180810170437-e96c4e24768d -) diff --git a/vendor/gotest.tools/LICENSE b/vendor/gotest.tools/v3/LICENSE similarity index 100% rename from vendor/gotest.tools/LICENSE rename to vendor/gotest.tools/v3/LICENSE diff --git a/vendor/gotest.tools/README.md b/vendor/gotest.tools/v3/README.md similarity index 68% rename from vendor/gotest.tools/README.md rename to vendor/gotest.tools/v3/README.md index 3155723dd..56b3e4ad2 100644 --- a/vendor/gotest.tools/README.md +++ b/vendor/gotest.tools/v3/README.md @@ -2,26 +2,41 @@ A collection of packages to augment `testing` and support common patterns. -[![GoDoc](https://godoc.org/gotest.tools?status.svg)](https://godoc.org/gotest.tools) +[![GoDoc](https://godoc.org/gotest.tools?status.svg)](http://gotest.tools) [![CircleCI](https://circleci.com/gh/gotestyourself/gotest.tools/tree/master.svg?style=shield)](https://circleci.com/gh/gotestyourself/gotest.tools/tree/master) [![Go Reportcard](https://goreportcard.com/badge/gotest.tools)](https://goreportcard.com/report/gotest.tools) +## Usage + +With Go modules enabled (go1.11+) + +``` +$ go get gotest.tools/v3 +``` + +``` +import "gotest.tools/v3/assert" +``` + +To use `gotest.tools` with an older version of Go that does not understand Go +module paths pin to version `v2.3.0`. + ## Packages -* [assert](http://godoc.org/gotest.tools/assert) - +* [assert](http://gotest.tools/assert) - compare values and fail the test when a comparison fails -* [env](http://godoc.org/gotest.tools/env) - +* [env](http://gotest.tools/env) - test code which uses environment variables -* [fs](http://godoc.org/gotest.tools/fs) - +* [fs](http://gotest.tools/fs) - create temporary files and compare a filesystem tree to an expected value -* [golden](http://godoc.org/gotest.tools/golden) - +* [golden](http://gotest.tools/golden) - compare large multi-line strings against values frozen in golden files -* [icmd](http://godoc.org/gotest.tools/icmd) - +* [icmd](http://gotest.tools/icmd) - execute binaries and test the output -* [poll](http://godoc.org/gotest.tools/poll) - +* [poll](http://gotest.tools/poll) - test asynchronous code by polling until a desired state is reached -* [skip](http://godoc.org/gotest.tools/skip) - +* [skip](http://gotest.tools/skip) - skip a test and print the source code of the condition used to skip the test ## Related diff --git a/vendor/gotest.tools/assert/assert.go b/vendor/gotest.tools/v3/assert/assert.go similarity index 79% rename from vendor/gotest.tools/assert/assert.go rename to vendor/gotest.tools/v3/assert/assert.go index 05d663543..e75d1f38a 100644 --- a/vendor/gotest.tools/assert/assert.go +++ b/vendor/gotest.tools/v3/assert/assert.go @@ -49,30 +49,31 @@ The example below shows assert used with some common types. Comparisons -Package https://godoc.org/gotest.tools/assert/cmp provides +Package http://gotest.tools/assert/cmp provides many common comparisons. Additional comparisons can be written to compare values in other ways. See the example Assert (CustomComparison). Automated migration from testify -gty-migrate-from-testify is a binary which can update source code which uses -testify assertions to use the assertions provided by this package. +gty-migrate-from-testify is a command which translates Go source code from +testify assertions to the assertions provided by this package. -See http://bit.do/cmd-gty-migrate-from-testify. +See http://gotest.tools/assert/cmd/gty-migrate-from-testify. */ -package assert // import "gotest.tools/assert" +package assert // import "gotest.tools/v3/assert" import ( "fmt" "go/ast" "go/token" + "reflect" gocmp "github.com/google/go-cmp/cmp" - "gotest.tools/assert/cmp" - "gotest.tools/internal/format" - "gotest.tools/internal/source" + "gotest.tools/v3/assert/cmp" + "gotest.tools/v3/internal/format" + "gotest.tools/v3/internal/source" ) // BoolOrComparison can be a bool, or cmp.Comparison. See Assert() for usage. @@ -118,8 +119,8 @@ func assert( return true case error: - msg := "error is not nil: " - t.Log(format.WithCustomMessage(failureMessage+msg+check.Error(), msgAndArgs...)) + msg := failureMsgFromError(check) + t.Log(format.WithCustomMessage(failureMessage+msg, msgAndArgs...)) case cmp.Comparison: success = runComparison(t, argSelector, check, msgAndArgs...) @@ -174,6 +175,15 @@ func logFailureFromBool(t TestingT, msgAndArgs ...interface{}) { t.Log(format.WithCustomMessage(failureMessage+msg, msgAndArgs...)) } +func failureMsgFromError(err error) string { + // Handle errors with non-nil types + v := reflect.ValueOf(err) + if v.Kind() == reflect.Ptr && v.IsNil() { + return fmt.Sprintf("error is not nil: error has type %T", err) + } + return "error is not nil: " + err.Error() +} + func boolFailureMessage(expr ast.Expr) (string, error) { if binaryExpr, ok := expr.(*ast.BinaryExpr); ok && binaryExpr.Op == token.NEQ { x, err := source.FormatNode(binaryExpr.X) @@ -202,17 +212,20 @@ func boolFailureMessage(expr ast.Expr) (string, error) { return "expression is false: " + formatted, nil } -// Assert performs a comparison. If the comparison fails the test is marked as +// Assert performs a comparison. If the comparison fails, the test is marked as // failed, a failure message is logged, and execution is stopped immediately. // -// The comparison argument may be one of three types: bool, cmp.Comparison or -// error. -// When called with a bool the failure message will contain the literal source -// code of the expression. -// When called with a cmp.Comparison the comparison is responsible for producing -// a helpful failure message. -// When called with an error a nil value is considered success. A non-nil error -// is a failure, and Error() is used as the failure message. +// The comparison argument may be one of three types: +// bool +// True is success. False is a failure. +// The failure message will contain the literal source code of the expression. +// cmp.Comparison +// Uses cmp.Result.Success() to check for success of failure. +// The comparison is responsible for producing a helpful failure message. +// http://gotest.tools/assert/cmp provides many common comparisons. +// error +// A nil value is considered success. +// A non-nil error is a failure, err.Error() is used as the failure message. func Assert(t TestingT, comparison BoolOrComparison, msgAndArgs ...interface{}) { if ht, ok := t.(helperT); ok { ht.Helper() @@ -260,10 +273,10 @@ func Equal(t TestingT, x, y interface{}, msgAndArgs ...interface{}) { assert(t, t.FailNow, argsAfterT, cmp.Equal(x, y), msgAndArgs...) } -// DeepEqual uses google/go-cmp (http://bit.do/go-cmp) to assert two values are -// equal and fails the test if they are not equal. +// DeepEqual uses google/go-cmp (https://godoc.org/github.com/google/go-cmp/cmp) +// to assert two values are equal and fails the test if they are not equal. // -// Package https://godoc.org/gotest.tools/assert/opt provides some additional +// Package http://gotest.tools/assert/opt provides some additional // commonly used Options. // // This is equivalent to Assert(t, cmp.DeepEqual(x, y)). @@ -295,14 +308,19 @@ func ErrorContains(t TestingT, err error, substring string, msgAndArgs ...interf } // ErrorType fails the test if err is nil, or err is not the expected type. +// Equivalent to Assert(t, cmp.ErrorType(err, expected)). // // Expected can be one of: -// a func(error) bool which returns true if the error is the expected type, -// an instance of (or a pointer to) a struct of the expected type, -// a pointer to an interface the error is expected to implement, -// a reflect.Type of the expected struct or interface. -// -// Equivalent to Assert(t, cmp.ErrorType(err, expected)). +// func(error) bool +// Function should return true if the error is the expected type. +// type struct{}, type &struct{} +// A struct or a pointer to a struct. +// Fails if the error is not of the same type as expected. +// type &interface{} +// A pointer to an interface type. +// Fails if err does not implement the interface. +// reflect.Type +// Fails if err does not implement the reflect.Type func ErrorType(t TestingT, err error, expected interface{}, msgAndArgs ...interface{}) { if ht, ok := t.(helperT); ok { ht.Helper() diff --git a/vendor/gotest.tools/assert/cmp/compare.go b/vendor/gotest.tools/v3/assert/cmp/compare.go similarity index 92% rename from vendor/gotest.tools/assert/cmp/compare.go rename to vendor/gotest.tools/v3/assert/cmp/compare.go index cf48d887a..bb3b24f43 100644 --- a/vendor/gotest.tools/assert/cmp/compare.go +++ b/vendor/gotest.tools/v3/assert/cmp/compare.go @@ -1,5 +1,5 @@ /*Package cmp provides Comparisons for Assert and Check*/ -package cmp // import "gotest.tools/assert/cmp" +package cmp // import "gotest.tools/v3/assert/cmp" import ( "fmt" @@ -8,7 +8,7 @@ import ( "strings" "github.com/google/go-cmp/cmp" - "gotest.tools/internal/format" + "gotest.tools/v3/internal/format" ) // Comparison is a function which compares values and returns ResultSuccess if @@ -16,11 +16,12 @@ import ( // Result will contain a message about why it failed. type Comparison func() Result -// DeepEqual compares two values using google/go-cmp (http://bit.do/go-cmp) +// DeepEqual compares two values using google/go-cmp +// (https://godoc.org/github.com/google/go-cmp/cmp) // and succeeds if the values are equal. // // The comparison can be customized using comparison Options. -// Package https://godoc.org/gotest.tools/assert/opt provides some additional +// Package http://gotest.tools/assert/opt provides some additional // commonly used Options. func DeepEqual(x, y interface{}, opts ...cmp.Option) Comparison { return func() (result Result) { @@ -103,10 +104,10 @@ func Equal(x, y interface{}) Comparison { return multiLineDiffResult(diff) } return ResultFailureTemplate(` - {{- .Data.x}} ( + {{- printf "%v" .Data.x}} ( {{- with callArg 0 }}{{ formatNode . }} {{end -}} {{- printf "%T" .Data.x -}} - ) != {{ .Data.y}} ( + ) != {{ printf "%v" .Data.y}} ( {{- with callArg 1 }}{{ formatNode . }} {{end -}} {{- printf "%T" .Data.y -}} )`, @@ -241,10 +242,12 @@ func ErrorContains(err error, substring string) Comparison { } } +type causer interface { + Cause() error +} + func formatErrorMessage(err error) string { - if _, ok := err.(interface { - Cause() error - }); ok { + if _, ok := err.(causer); ok { return fmt.Sprintf("%q\n%+v", err, err) } // This error was not wrapped with github.com/pkg/errors @@ -283,10 +286,16 @@ func isNil(obj interface{}, msgFunc func(reflect.Value) string) Comparison { // ErrorType succeeds if err is not nil and is of the expected type. // // Expected can be one of: -// a func(error) bool which returns true if the error is the expected type, -// an instance of (or a pointer to) a struct of the expected type, -// a pointer to an interface the error is expected to implement, -// a reflect.Type of the expected struct or interface. +// func(error) bool +// Function should return true if the error is the expected type. +// type struct{}, type &struct{} +// A struct or a pointer to a struct. +// Fails if the error is not of the same type as expected. +// type &interface{} +// A pointer to an interface type. +// Fails if err does not implement the interface. +// reflect.Type +// Fails if err does not implement the reflect.Type func ErrorType(err error, expected interface{}) Comparison { return func() Result { switch expectedType := expected.(type) { diff --git a/vendor/gotest.tools/assert/cmp/result.go b/vendor/gotest.tools/v3/assert/cmp/result.go similarity index 98% rename from vendor/gotest.tools/assert/cmp/result.go rename to vendor/gotest.tools/v3/assert/cmp/result.go index 204edda4b..385e1a087 100644 --- a/vendor/gotest.tools/assert/cmp/result.go +++ b/vendor/gotest.tools/v3/assert/cmp/result.go @@ -6,7 +6,7 @@ import ( "go/ast" "text/template" - "gotest.tools/internal/source" + "gotest.tools/v3/internal/source" ) // A Result of a Comparison. diff --git a/vendor/gotest.tools/assert/result.go b/vendor/gotest.tools/v3/assert/result.go similarity index 95% rename from vendor/gotest.tools/assert/result.go rename to vendor/gotest.tools/v3/assert/result.go index 949d93961..d77860b58 100644 --- a/vendor/gotest.tools/assert/result.go +++ b/vendor/gotest.tools/v3/assert/result.go @@ -4,9 +4,9 @@ import ( "fmt" "go/ast" - "gotest.tools/assert/cmp" - "gotest.tools/internal/format" - "gotest.tools/internal/source" + "gotest.tools/v3/assert/cmp" + "gotest.tools/v3/internal/format" + "gotest.tools/v3/internal/source" ) func runComparison( diff --git a/vendor/gotest.tools/v3/go.mod b/vendor/gotest.tools/v3/go.mod new file mode 100644 index 000000000..4ae9354e5 --- /dev/null +++ b/vendor/gotest.tools/v3/go.mod @@ -0,0 +1,10 @@ +module gotest.tools/v3 + +require ( + github.com/google/go-cmp v0.3.0 + github.com/pkg/errors v0.8.1 + github.com/spf13/pflag v1.0.3 + golang.org/x/tools v0.0.0-20190624222133-a101b041ded4 +) + +go 1.11 diff --git a/vendor/gotest.tools/internal/difflib/LICENSE b/vendor/gotest.tools/v3/internal/difflib/LICENSE similarity index 100% rename from vendor/gotest.tools/internal/difflib/LICENSE rename to vendor/gotest.tools/v3/internal/difflib/LICENSE diff --git a/vendor/gotest.tools/internal/difflib/difflib.go b/vendor/gotest.tools/v3/internal/difflib/difflib.go similarity index 99% rename from vendor/gotest.tools/internal/difflib/difflib.go rename to vendor/gotest.tools/v3/internal/difflib/difflib.go index b6f486b9c..9bf506b6b 100644 --- a/vendor/gotest.tools/internal/difflib/difflib.go +++ b/vendor/gotest.tools/v3/internal/difflib/difflib.go @@ -4,7 +4,7 @@ Original source: https://github.com/pmezard/go-difflib This file is trimmed to only the parts used by this repository. */ -package difflib // import "gotest.tools/internal/difflib" +package difflib // import "gotest.tools/v3/internal/difflib" func min(a, b int) int { if a < b { diff --git a/vendor/gotest.tools/internal/format/diff.go b/vendor/gotest.tools/v3/internal/format/diff.go similarity index 99% rename from vendor/gotest.tools/internal/format/diff.go rename to vendor/gotest.tools/v3/internal/format/diff.go index c938c97be..9897d4b9d 100644 --- a/vendor/gotest.tools/internal/format/diff.go +++ b/vendor/gotest.tools/v3/internal/format/diff.go @@ -6,7 +6,7 @@ import ( "strings" "unicode" - "gotest.tools/internal/difflib" + "gotest.tools/v3/internal/difflib" ) const ( diff --git a/vendor/gotest.tools/internal/format/format.go b/vendor/gotest.tools/v3/internal/format/format.go similarity index 91% rename from vendor/gotest.tools/internal/format/format.go rename to vendor/gotest.tools/v3/internal/format/format.go index 8f6494f99..5097e4bd6 100644 --- a/vendor/gotest.tools/internal/format/format.go +++ b/vendor/gotest.tools/v3/internal/format/format.go @@ -1,4 +1,4 @@ -package format // import "gotest.tools/internal/format" +package format // import "gotest.tools/v3/internal/format" import "fmt" diff --git a/vendor/gotest.tools/internal/source/defers.go b/vendor/gotest.tools/v3/internal/source/defers.go similarity index 100% rename from vendor/gotest.tools/internal/source/defers.go rename to vendor/gotest.tools/v3/internal/source/defers.go diff --git a/vendor/gotest.tools/internal/source/source.go b/vendor/gotest.tools/v3/internal/source/source.go similarity index 91% rename from vendor/gotest.tools/internal/source/source.go rename to vendor/gotest.tools/v3/internal/source/source.go index 8a5d0e8d3..134afb6ba 100644 --- a/vendor/gotest.tools/internal/source/source.go +++ b/vendor/gotest.tools/v3/internal/source/source.go @@ -1,4 +1,4 @@ -package source // import "gotest.tools/internal/source" +package source // import "gotest.tools/v3/internal/source" import ( "bytes" @@ -92,7 +92,9 @@ func nodePosition(fileset *token.FileSet, node ast.Node) token.Position { return fileset.Position(node.Pos()) } -var goVersionBefore19 = func() bool { +// GoVersionLessThan returns true if runtime.Version() is semantically less than +// version 1.minor. +func GoVersionLessThan(minor int64) bool { version := runtime.Version() // not a release version if !strings.HasPrefix(version, "go") { @@ -103,9 +105,11 @@ var goVersionBefore19 = func() bool { if len(parts) < 2 { return false } - minor, err := strconv.ParseInt(parts[1], 10, 32) - return err == nil && parts[0] == "1" && minor < 9 -}() + actual, err := strconv.ParseInt(parts[1], 10, 32) + return err == nil && parts[0] == "1" && actual < minor +} + +var goVersionBefore19 = GoVersionLessThan(9) func getCallExprArgs(node ast.Node) ([]ast.Expr, error) { visitor := &callExprVisitor{}