From db7cb1dbfcfd4f05858e7579f33bfbb91b458666 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 4 Jul 2023 15:16:42 +0200 Subject: [PATCH] test/tools: vendor ginkgo v2.11 Ginkgo currently logs a warning because the cli version (defnied in test/tools/go.mod) does not match the library version (defnied in go.mod). Simply fix this by updating ginkgo to the latest version. Signed-off-by: Paul Holzinger --- test/tools/go.mod | 2 +- test/tools/go.sum | 6 +++--- .../ginkgo/v2/ginkgo/generators/generate_command.go | 5 +++++ .../v2/ginkgo/generators/generate_templates.go | 6 ++++-- .../ginkgo/v2/ginkgo/generators/generators_common.go | 12 ++++++++++++ .../github.com/onsi/ginkgo/v2/types/version.go | 2 +- test/tools/vendor/modules.txt | 2 +- 7 files changed, 27 insertions(+), 8 deletions(-) diff --git a/test/tools/go.mod b/test/tools/go.mod index 3ebec32f44..2dceb2eb03 100644 --- a/test/tools/go.mod +++ b/test/tools/go.mod @@ -4,7 +4,7 @@ go 1.18 require ( github.com/cpuguy83/go-md2man/v2 v2.0.2 - github.com/onsi/ginkgo/v2 v2.9.6 + github.com/onsi/ginkgo/v2 v2.11.0 github.com/vbatts/git-validation v1.2.0 golang.org/x/tools v0.10.0 ) diff --git a/test/tools/go.sum b/test/tools/go.sum index b563bc2e06..2037ab6c10 100644 --- a/test/tools/go.sum +++ b/test/tools/go.sum @@ -17,9 +17,9 @@ github.com/hashicorp/go-version v1.3.0 h1:McDWVJIU/y+u1BRV06dPaLfLCaT7fUTJLp5r04 github.com/hashicorp/go-version v1.3.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/onsi/ginkgo/v2 v2.9.6 h1:QPnYLUAuyyKYVInVqnaBV+4k+r6LZ27+iBGAOcqNPHE= -github.com/onsi/ginkgo/v2 v2.9.6/go.mod h1:cxrmXWykAwTwhQsJOPfdIDiJ+l2RYq7U8hFU+M/1uw0= -github.com/onsi/gomega v1.27.7 h1:fVih9JD6ogIiHUN6ePK7HJidyEDpWGVB5mzM7cWNXoU= +github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU= +github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM= +github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= diff --git a/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generate_command.go b/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generate_command.go index 48d23f9191..be01dec979 100644 --- a/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generate_command.go +++ b/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generate_command.go @@ -32,6 +32,9 @@ func BuildGenerateCommand() command.Command { {Name: "template-data", KeyPath: "CustomTemplateData", UsageArgument: "template-data-file", Usage: "If specified, generate will use the contents of the file passed as data to be rendered in the test file template"}, + {Name: "tags", KeyPath: "Tags", + UsageArgument: "build-tags", + Usage: "If specified, generate will create a test file that uses the given build tags (i.e. `--tags e2e,!unit` will add `//go:build e2e,!unit`)"}, }, &conf, types.GinkgoFlagSections{}, @@ -59,6 +62,7 @@ You can also pass a of the form "file.go" and generate will emit "fil } type specData struct { + BuildTags string Package string Subject string PackageImportPath string @@ -93,6 +97,7 @@ func generateTestFileForSubject(subject string, conf GeneratorsConfig) { } data := specData{ + BuildTags: getBuildTags(conf.Tags), Package: determinePackageName(packageName, conf.Internal), Subject: formattedName, PackageImportPath: getPackageImportPath(), diff --git a/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generate_templates.go b/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generate_templates.go index c3470adbfd..4dab07d036 100644 --- a/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generate_templates.go +++ b/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generate_templates.go @@ -1,6 +1,7 @@ package generators -var specText = `package {{.Package}} +var specText = `{{.BuildTags}} +package {{.Package}} import ( {{.GinkgoImport}} @@ -14,7 +15,8 @@ var _ = {{.GinkgoPackage}}Describe("{{.Subject}}", func() { }) ` -var agoutiSpecText = `package {{.Package}} +var agoutiSpecText = `{{.BuildTags}} +package {{.Package}} import ( {{.GinkgoImport}} diff --git a/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generators_common.go b/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generators_common.go index 3046a4487a..28c7aa6f43 100644 --- a/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generators_common.go +++ b/test/tools/vendor/github.com/onsi/ginkgo/v2/ginkgo/generators/generators_common.go @@ -1,6 +1,7 @@ package generators import ( + "fmt" "go/build" "os" "path/filepath" @@ -14,6 +15,7 @@ type GeneratorsConfig struct { Agouti, NoDot, Internal bool CustomTemplate string CustomTemplateData string + Tags string } func getPackageAndFormattedName() (string, string, string) { @@ -62,3 +64,13 @@ func determinePackageName(name string, internal bool) string { return name + "_test" } + +// getBuildTags returns the resultant string to be added. +// If the input string is not empty, then returns a `//go:build {}` string, +// otherwise returns an empty string. +func getBuildTags(tags string) string { + if tags != "" { + return fmt.Sprintf("//go:build %s\n", tags) + } + return "" +} diff --git a/test/tools/vendor/github.com/onsi/ginkgo/v2/types/version.go b/test/tools/vendor/github.com/onsi/ginkgo/v2/types/version.go index 2ca1f7ba00..f895739b83 100644 --- a/test/tools/vendor/github.com/onsi/ginkgo/v2/types/version.go +++ b/test/tools/vendor/github.com/onsi/ginkgo/v2/types/version.go @@ -1,3 +1,3 @@ package types -const VERSION = "2.9.6" +const VERSION = "2.11.0" diff --git a/test/tools/vendor/modules.txt b/test/tools/vendor/modules.txt index c65f4d60e2..5aace32db4 100644 --- a/test/tools/vendor/modules.txt +++ b/test/tools/vendor/modules.txt @@ -11,7 +11,7 @@ github.com/google/pprof/profile # github.com/hashicorp/go-version v1.3.0 ## explicit github.com/hashicorp/go-version -# github.com/onsi/ginkgo/v2 v2.9.6 +# github.com/onsi/ginkgo/v2 v2.11.0 ## explicit; go 1.18 github.com/onsi/ginkgo/v2/config github.com/onsi/ginkgo/v2/formatter