From 0de0e7c5ca2613c002a4bec010be43436f4fb196 Mon Sep 17 00:00:00 2001 From: Sandre <56088201+erdnas@users.noreply.github.com> Date: Wed, 29 Mar 2023 03:53:30 +0100 Subject: [PATCH 01/23] add newlines to GinkgoLogr (#1170) (#1171) --- internal/writer.go | 2 +- internal/writer_test.go | 11 +++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/internal/writer.go b/internal/writer.go index 28a45b0fa..574f172df 100644 --- a/internal/writer.go +++ b/internal/writer.go @@ -135,6 +135,6 @@ func (w *Writer) Println(a ...interface{}) { func GinkgoLogrFunc(writer *Writer) logr.Logger { return funcr.New(func(prefix, args string) { - writer.Printf("%s", args) + writer.Printf("%s\n", args) }, funcr.Options{}) } diff --git a/internal/writer_test.go b/internal/writer_test.go index 63f8d87e1..bb4941206 100644 --- a/internal/writer_test.go +++ b/internal/writer_test.go @@ -129,13 +129,20 @@ var _ = Describe("Writer", func() { It("can print Info logs", func() { log := internal.GinkgoLogrFunc(writer) log.Info("message", "key", 5) - Ω(string(out.Contents())).Should(Equal(" \"level\"=0 \"msg\"=\"message\" \"key\"=5")) + Ω(string(out.Contents())).Should(Equal(" \"level\"=0 \"msg\"=\"message\" \"key\"=5\n")) }) It("can print Error logs", func() { log := internal.GinkgoLogrFunc(writer) log.Error(errors.New("cake"), "planned failure", "key", "banana") - Ω(string(out.Contents())).Should(Equal(" \"msg\"=\"planned failure\" \"error\"=\"cake\" \"key\"=\"banana\"")) + Ω(string(out.Contents())).Should(Equal(" \"msg\"=\"planned failure\" \"error\"=\"cake\" \"key\"=\"banana\"\n")) + }) + + It("can print multiple logs", func() { + log := internal.GinkgoLogrFunc(writer) + log.Info("message", "key", 5) + log.Error(errors.New("cake"), "planned failure", "key", "banana") + Ω(string(out.Contents())).Should(Equal(" \"level\"=0 \"msg\"=\"message\" \"key\"=5\n \"msg\"=\"planned failure\" \"error\"=\"cake\" \"key\"=\"banana\"\n")) }) }) }) From 227c662e819019ad42d3b6f3144cba3caa65023d Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Thu, 30 Mar 2023 16:54:50 -0600 Subject: [PATCH 02/23] updqte Measure deprecation message. fixes #1176 --- integration/deprecations_test.go | 2 +- types/deprecation_support.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/deprecations_test.go b/integration/deprecations_test.go index 87014069c..fda9396e0 100644 --- a/integration/deprecations_test.go +++ b/integration/deprecations_test.go @@ -17,7 +17,7 @@ var _ = Describe("Deprecations", func() { contents := string(session.Out.Contents()) + string(session.Err.Contents()) Ω(contents).Should(ContainSubstring("You are passing a Done channel to a test node to test asynchronous behavior.")) - Ω(contents).Should(ContainSubstring("Measure is deprecated and will be removed in Ginkgo V2.")) + Ω(contents).Should(ContainSubstring("Measure is deprecated and has been removed from Ginkgo V2.")) Ω(contents).Should(ContainSubstring("--stream is deprecated")) Ω(contents).Should(ContainSubstring("--randomizeAllSpecs is deprecated")) }) diff --git a/types/deprecation_support.go b/types/deprecation_support.go index f267bdefd..e2519f673 100644 --- a/types/deprecation_support.go +++ b/types/deprecation_support.go @@ -38,7 +38,7 @@ func (d deprecations) Async() Deprecation { func (d deprecations) Measure() Deprecation { return Deprecation{ - Message: "Measure is deprecated and will be removed in Ginkgo V2. Please migrate to gomega/gmeasure.", + Message: "Measure is deprecated and has been removed from Ginkgo V2. Any Measure tests in your spec will not run. Please migrate to gomega/gmeasure.", DocLink: "removed-measure", Version: "1.16.3", } From 8e423e5e15be0b26c9e3d9ca2a9a05e513814c7d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 10:51:47 +0100 Subject: [PATCH 03/23] Bump golang.org/x/sys from 0.6.0 to 0.7.0 (#1179) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.6.0 to 0.7.0. - [Release notes](https://github.com/golang/sys/releases) - [Commits](https://github.com/golang/sys/compare/v0.6.0...v0.7.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 91e121960..11b12fe40 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 github.com/onsi/gomega v1.27.4 golang.org/x/net v0.8.0 - golang.org/x/sys v0.6.0 + golang.org/x/sys v0.7.0 golang.org/x/tools v0.7.0 ) diff --git a/go.sum b/go.sum index 3315ebca4..254fb2ad1 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= +golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= From f41c557d462194fe704bd919af62badeb416a2c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 10:52:51 +0100 Subject: [PATCH 04/23] Bump github.com/go-logr/logr from 1.2.3 to 1.2.4 (#1174) Bumps [github.com/go-logr/logr](https://github.com/go-logr/logr) from 1.2.3 to 1.2.4. - [Release notes](https://github.com/go-logr/logr/releases) - [Changelog](https://github.com/go-logr/logr/blob/master/CHANGELOG.md) - [Commits](https://github.com/go-logr/logr/compare/v1.2.3...v1.2.4) --- updated-dependencies: - dependency-name: github.com/go-logr/logr dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 11b12fe40..405f5ad8a 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module github.com/onsi/ginkgo/v2 go 1.18 require ( - github.com/go-logr/logr v1.2.3 + github.com/go-logr/logr v1.2.4 github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 github.com/onsi/gomega v1.27.4 diff --git a/go.sum b/go.sum index 254fb2ad1..4ee0d7e21 100644 --- a/go.sum +++ b/go.sum @@ -4,8 +4,8 @@ github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMn github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= -github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ= +github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= From 0a2bc6438f77c5eb598c0e2c3162cf8e010f54b5 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 11:01:02 +0100 Subject: [PATCH 05/23] Bump github.com/onsi/gomega from 1.27.4 to 1.27.6 (#1173) Bumps [github.com/onsi/gomega](https://github.com/onsi/gomega) from 1.27.4 to 1.27.6. - [Release notes](https://github.com/onsi/gomega/releases) - [Changelog](https://github.com/onsi/gomega/blob/master/CHANGELOG.md) - [Commits](https://github.com/onsi/gomega/compare/v1.27.4...v1.27.6) --- updated-dependencies: - dependency-name: github.com/onsi/gomega dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 405f5ad8a..c469b0c5c 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/go-logr/logr v1.2.4 github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 - github.com/onsi/gomega v1.27.4 + github.com/onsi/gomega v1.27.6 golang.org/x/net v0.8.0 golang.org/x/sys v0.7.0 golang.org/x/tools v0.7.0 diff --git a/go.sum b/go.sum index 4ee0d7e21..847d7f42b 100644 --- a/go.sum +++ b/go.sum @@ -17,8 +17,8 @@ github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeN github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= -github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ= +github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE= +github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg= 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/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= From 73ed75b9f74756a058df23dc31b39bcc463de0cb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 5 Apr 2023 11:04:37 +0100 Subject: [PATCH 06/23] Bump actions/setup-go from 3 to 4 (#1164) Bumps [actions/setup-go](https://github.com/actions/setup-go) from 3 to 4. - [Release notes](https://github.com/actions/setup-go/releases) - [Commits](https://github.com/actions/setup-go/compare/v3...v4) --- updated-dependencies: - dependency-name: actions/setup-go dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c25208a64..df4e3aefd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-latest name: Check modules steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: '1.19' - uses: actions/checkout@v3 @@ -22,7 +22,7 @@ jobs: version: [ '1.19', '1.20' ] name: Go ${{ matrix.version }} steps: - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: go-version: ${{ matrix.version }} - uses: actions/checkout@v3 From b453793b607ade42b5f4192ea53cd6a4244a73ff Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 10 Apr 2023 22:07:08 +0100 Subject: [PATCH 07/23] Bump golang.org/x/tools from 0.7.0 to 0.8.0 (#1182) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.7.0 to 0.8.0. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 6 +++--- go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go.mod b/go.mod index c469b0c5c..6ef8236ea 100644 --- a/go.mod +++ b/go.mod @@ -7,15 +7,15 @@ require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 github.com/onsi/gomega v1.27.6 - golang.org/x/net v0.8.0 + golang.org/x/net v0.9.0 golang.org/x/sys v0.7.0 - golang.org/x/tools v0.7.0 + golang.org/x/tools v0.8.0 ) require ( github.com/golang/protobuf v1.5.3 // indirect github.com/google/go-cmp v0.5.9 // indirect - golang.org/x/text v0.8.0 // indirect + golang.org/x/text v0.9.0 // indirect google.golang.org/protobuf v1.28.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 847d7f42b..e0e847a1b 100644 --- a/go.sum +++ b/go.sum @@ -24,15 +24,15 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/net v0.8.0 h1:Zrh2ngAOFYneWTAIAPethzeaQLuHwhuBkuV6ZiRnUaQ= -golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= +golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= +golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.8.0 h1:57P1ETyNKtuIjB4SRd15iJxuhj8Gc416Y78H3qgMh68= -golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4= -golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s= +golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= +golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= From e3795a44abfdf52cfa671bfa545eac23bfcbf435 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 22:50:25 +0100 Subject: [PATCH 08/23] Bump nokogiri from 1.14.1 to 1.14.3 in /docs (#1184) Bumps [nokogiri](https://github.com/sparklemotion/nokogiri) from 1.14.1 to 1.14.3. - [Release notes](https://github.com/sparklemotion/nokogiri/releases) - [Changelog](https://github.com/sparklemotion/nokogiri/blob/main/CHANGELOG.md) - [Commits](https://github.com/sparklemotion/nokogiri/compare/v1.14.1...v1.14.3) --- updated-dependencies: - dependency-name: nokogiri dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- docs/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 7b1ab51a4..5278fed5d 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -211,7 +211,7 @@ GEM jekyll-feed (~> 0.9) jekyll-seo-tag (~> 2.1) minitest (5.17.0) - nokogiri (1.14.1-x86_64-linux) + nokogiri (1.14.3-x86_64-linux) racc (~> 1.4) octokit (4.25.1) faraday (>= 1, < 3) From 8b925abe6639e4bfd62b9defc35c5da41da08d6a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 20 Apr 2023 22:50:35 +0100 Subject: [PATCH 09/23] Bump commonmarker from 0.23.8 to 0.23.9 in /docs (#1183) Bumps [commonmarker](https://github.com/gjtorikian/commonmarker) from 0.23.8 to 0.23.9. - [Release notes](https://github.com/gjtorikian/commonmarker/releases) - [Changelog](https://github.com/gjtorikian/commonmarker/blob/main/CHANGELOG.md) - [Commits](https://github.com/gjtorikian/commonmarker/compare/v0.23.8...v0.23.9) --- updated-dependencies: - dependency-name: commonmarker dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- docs/Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/Gemfile.lock b/docs/Gemfile.lock index 5278fed5d..0c545e5c8 100644 --- a/docs/Gemfile.lock +++ b/docs/Gemfile.lock @@ -14,7 +14,7 @@ GEM execjs coffee-script-source (1.11.1) colorator (1.1.0) - commonmarker (0.23.8) + commonmarker (0.23.9) concurrent-ruby (1.2.0) dnsruby (1.61.9) simpleidn (~> 0.1) From c0c77b692d00eaa5e93d18b1e6ff837ff10a7c33 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Tue, 2 May 2023 21:17:47 -0600 Subject: [PATCH 10/23] Add RenderTimeline to GinkgoT() --- ginkgo_t_dsl.go | 3 ++ internal/testingtproxy/testing_t_proxy.go | 4 +++ internal/testingtproxy/testingtproxy_test.go | 36 ++++++++++++++++++-- reporters/junit_report.go | 6 +++- 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/ginkgo_t_dsl.go b/ginkgo_t_dsl.go index 17073145f..28447ffdd 100644 --- a/ginkgo_t_dsl.go +++ b/ginkgo_t_dsl.go @@ -80,6 +80,9 @@ type FullGinkgoTInterface interface { Fi(indentation uint, format string, args ...any) string Fiw(indentation uint, maxWidth uint, format string, args ...any) string + //Generates a formatted string version of the current spec's timeline + RenderTimeline() string + GinkgoRecover() DeferCleanup(args ...any) diff --git a/internal/testingtproxy/testing_t_proxy.go b/internal/testingtproxy/testing_t_proxy.go index 92acc0a00..73e265565 100644 --- a/internal/testingtproxy/testing_t_proxy.go +++ b/internal/testingtproxy/testing_t_proxy.go @@ -7,6 +7,7 @@ import ( "github.com/onsi/ginkgo/v2/formatter" "github.com/onsi/ginkgo/v2/internal" + "github.com/onsi/ginkgo/v2/reporters" "github.com/onsi/ginkgo/v2/types" ) @@ -185,6 +186,9 @@ func (t *ginkgoTestingTProxy) Fi(indentation uint, format string, args ...any) s func (t *ginkgoTestingTProxy) Fiw(indentation uint, maxWidth uint, format string, args ...any) string { return t.f.Fiw(indentation, maxWidth, format, args...) } +func (t *ginkgoTestingTProxy) RenderTimeline() string { + return reporters.RenderTimeline(t.report(), false) +} func (t *ginkgoTestingTProxy) GinkgoRecover() { t.ginkgoRecover() } diff --git a/internal/testingtproxy/testingtproxy_test.go b/internal/testingtproxy/testingtproxy_test.go index 35dbe497e..22a3e9242 100644 --- a/internal/testingtproxy/testingtproxy_test.go +++ b/internal/testingtproxy/testingtproxy_test.go @@ -3,6 +3,7 @@ package testingtproxy_test import ( "os" "runtime" + "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" @@ -301,18 +302,47 @@ var _ = Describe("Testingtproxy", func() { Ω(string(buf.Contents())).Should(Equal(" hi 3\n")) }) - It("can provides a correctly configured Ginkgo Formatter", func() { + It("can provide a correctly configured Ginkgo Formatter", func() { Ω(t.F("{{blue}}%d{{/}}", 3)).Should(Equal("3")) }) - It("can printf to the GinkgoWriter", func() { + It("can provide a correctly configured Ginkgo Formatter, with indentation", func() { Ω(t.Fi(1, "{{blue}}%d{{/}}", 3)).Should(Equal(" 3")) }) - It("can println to the GinkgoWriter", func() { + It("can provide a correctly configured Ginkgo Formatter, with indentation and width constraints", func() { Ω(t.Fiw(1, 5, "{{blue}}%d{{/}} a number", 3)).Should(Equal(" 3 a\n number")) }) + It("can render the timeline of the current spec", func() { + cl := types.NewCustomCodeLocation("cl") + reportToReturn.CapturedGinkgoWriterOutput = "ABCDEFGHIJKLMNOP" + reportToReturn.SpecEvents = append(reportToReturn.SpecEvents, types.SpecEvent{ + TimelineLocation: types.TimelineLocation{Offset: 5, Order: 1}, + SpecEventType: types.SpecEventNodeStart, + Message: "The Test", + CodeLocation: cl, + NodeType: types.NodeTypeIt, + }) + reportToReturn.SpecEvents = append(reportToReturn.SpecEvents, types.SpecEvent{ + TimelineLocation: types.TimelineLocation{Offset: 10, Order: 3}, + SpecEventType: types.SpecEventNodeEnd, + Message: "The Test", + CodeLocation: cl, + NodeType: types.NodeTypeIt, + Duration: time.Second, + }) + reportToReturn.State = types.SpecStateFailed + reportToReturn.Failure = types.Failure{ + Message: "The Failure", + FailureNodeType: types.NodeTypeIt, + Location: cl, + TimelineLocation: types.TimelineLocation{Offset: 10, Order: 2}, + } + + Ω(t.RenderTimeline()).Should(Equal("ABCDE\n> Enter \x1b[1m[It]\x1b[0m The Test \x1b[38;5;243m- cl @ 01/01/01 00:00:00\x1b[0m\nFGHIJ\n\x1b[38;5;9m[FAILED] The Failure\x1b[0m\n\x1b[38;5;9mIn \x1b[1m[It]\x1b[0m\x1b[38;5;9m at: \x1b[1mcl\x1b[0m \x1b[38;5;243m@ 01/01/01 00:00:00\x1b[0m\n< Exit \x1b[1m[It]\x1b[0m The Test \x1b[38;5;243m- cl @ 01/01/01 00:00:00 (1s)\x1b[0m\nKLMNOP")) + }) + It("can provide GinkgoRecover", func() { Ω(recoverCall).Should(BeFalse()) t.GinkgoRecover() diff --git a/reporters/junit_report.go b/reporters/junit_report.go index ca98609d0..592d7f614 100644 --- a/reporters/junit_report.go +++ b/reporters/junit_report.go @@ -344,8 +344,12 @@ func failureDescriptionForUnstructuredReporters(spec types.SpecReport) string { } func systemErrForUnstructuredReporters(spec types.SpecReport) string { + return RenderTimeline(spec, true) +} + +func RenderTimeline(spec types.SpecReport, noColor bool) string { out := &strings.Builder{} - NewDefaultReporter(types.ReporterConfig{NoColor: true, VeryVerbose: true}, out).emitTimeline(0, spec, spec.Timeline()) + NewDefaultReporter(types.ReporterConfig{NoColor: noColor, VeryVerbose: true}, out).emitTimeline(0, spec, spec.Timeline()) return out.String() } From 7a8249ea52743eee1a5cf127a1959c2169b029c8 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Tue, 2 May 2023 21:19:48 -0600 Subject: [PATCH 11/23] v2.9.3 --- CHANGELOG.md | 18 ++++++++++++++++++ types/version.go | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e779fe64..5a4b9cc76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,21 @@ +## 2.9.3 + +### Features +- Add RenderTimeline to GinkgoT() [c0c77b6] + +### Fixes +- update Measure deprecation message. fixes #1176 [227c662] +- add newlines to GinkgoLogr (#1170) (#1171) [0de0e7c] + +### Maintenance +- Bump commonmarker from 0.23.8 to 0.23.9 in /docs (#1183) [8b925ab] +- Bump nokogiri from 1.14.1 to 1.14.3 in /docs (#1184) [e3795a4] +- Bump golang.org/x/tools from 0.7.0 to 0.8.0 (#1182) [b453793] +- Bump actions/setup-go from 3 to 4 (#1164) [73ed75b] +- Bump github.com/onsi/gomega from 1.27.4 to 1.27.6 (#1173) [0a2bc64] +- Bump github.com/go-logr/logr from 1.2.3 to 1.2.4 (#1174) [f41c557] +- Bump golang.org/x/sys from 0.6.0 to 0.7.0 (#1179) [8e423e5] + ## 2.9.2 ### Maintenance diff --git a/types/version.go b/types/version.go index 8e7f7404f..38920a439 100644 --- a/types/version.go +++ b/types/version.go @@ -1,3 +1,3 @@ package types -const VERSION = "2.9.2" +const VERSION = "2.9.3" From 6c7f8bb30137f60b912e724e6319f9307040d409 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Wed, 3 May 2023 08:23:24 -0600 Subject: [PATCH 12/23] update TODO file in .gitignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index edf0231cd..18793c248 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ .DS_Store -TODO.md +TODO tmp/**/* *.coverprofile .vscode From 15d4bdc9f8d4d43e1739e0862604d643e03ce2bf Mon Sep 17 00:00:00 2001 From: Paul Holzinger <45212748+Luap99@users.noreply.github.com> Date: Wed, 3 May 2023 16:50:03 +0200 Subject: [PATCH 13/23] fix hang with ginkgo -p (#1192) * integration: build interceptor binary automatically Trying to run this locally the interceptor binary did not exists. Lets just build this in SynchronizedBeforeSuite() automatically so users do not have to figure this out. Signed-off-by: Paul Holzinger * integration: make interceptor test parallel safe Using the same file name for all test cause conflicts when run in parallel, this causes the tests to fail for me. To fix this use a filename suffix with GinkgoParallelProcess() which prevents conflicts in the file name. Signed-off-by: Paul Holzinger * fix hang with ginkgo -p When you run any child process that stay around longer than the test suite ginkgo currently hangs. This is because the dup stdout/err fds are leaked into the child thus read() will block on it as there is at least one process still having the write pipe open. From ginkgos POV it looks like it is done, you see the ginkgo result output printed but then it just hangs and doe snot exit because of it. To fix it we set FD_CLOEXEC on the dup-ed fds, this prevents them from ever being leaking into other processes that could outlive the suite. There is a dup3() call the could be uses to set the CLOEXEC option directly but this seem linux only and thus is less portable. The fcntl call should be good enough here, we do not need to be worried about the race conditions described in the man page. Ideally we should do some error handling in that function for both the fcntl calls and the existing dup() above, however this seems like a rather big change. I am not so sure about how to test it properly, I added a test which just executes `ginkgo run -p` and a test which only starts `sleep 60`. Ginkgo then should exit right way and keep this process running. Then I just make sure the gingo exits in under 15 seconds. As long as it is below 60s it should fulfil the purpose. Fixes #1191 Signed-off-by: Paul Holzinger * Rearrange new interceptor hang tests and confirm they cover the issue in question --------- Signed-off-by: Paul Holzinger Co-authored-by: Onsi Fakhouri --- TODO | 60 +++++++++++++++++++ .../interceptor_fixture_suite_test.go | 25 ++++++++ integration/output_interceptor_test.go | 18 ++++++ internal/output_interceptor_unix.go | 11 ++++ 4 files changed, 114 insertions(+) create mode 100644 TODO create mode 100644 integration/_fixtures/interceptor_sleep_fixture/interceptor_fixture_suite_test.go diff --git a/TODO b/TODO new file mode 100644 index 000000000..8a44c4b69 --- /dev/null +++ b/TODO @@ -0,0 +1,60 @@ +# Backlog +[] @G fix hang with ginkgo -p + https://github.com/onsi/ginkgo/issues/1192 +[] @B biloba needs to support "McDonald's" +[] @G Document order of execution for setup nodes on the same level + https://github.com/onsi/ginkgo/issues/1172 +[] @G fail fast may cause Serial spec or cleanup Node interrupted + https://github.com/onsi/ginkgo/issues/1178 + +# Needs-Prioritization +[] @G Pull JUnit config out of code and into flags/config files + https://github.com/onsi/ginkgo/issues/1115 +[] @G -exec support for `ginkgo run` + https://github.com/onsi/ginkgo/issues/869 +[] @G Add `indent` to gcustom +[] @G HaveField should not panic in FailureMessage if the field is non-existant. It should return a meaningful failure message. +[] @G allow NodeTimeout and GracePeriod to live on containers and propagate down +[] @G Clean up ReportEntry decoding: + func (entry ReportEntry) DecodeValue(p interface{}) error { + // if raw is assignable to p, assign + // else - parse AsJSON + } +[] @B Biloba lets you get all innerHTML and emit it on failure +[] @B equivalent of puppeteer text selector? +[] @B how do we invoke async functions? what does await look like for those? maybe time to actually read? goal: remove the separate muhasibPostLogin function. +[] @B https://github.com/onsi/biloba/issues/2 +[] @B right now polling an element fails if the browser if ollowing redirects. so i'm using Eventually(b.Location) - instead of just Eventually("#el").Should(b.Exist()). I think we need a more robust way to ensure biloba. +[] @B biloba support for gettign "SelectedOption" instead of just "Value" for select inputs (e.g. b.OptionByName(...) instead of value?) +[] @B ginkgo interrupt should not show the whole stacktrace. it's just too much! +[] @B add cookie support + chromedp.Run(b.Context, chromedp.ActionFunc(func(ctx context.Context) error { + return storage.ClearDataForOrigin("*", "all").Do(ctx) + })) + + chromedp.Run(b.Context, chromedp.ActionFunc(func(ctx context.Context) error { + expr := cdp.TimeSinceEpoch(time.Date(2091, 28, 3, 1, 40, 45, 0, time.UTC)) + return storage.SetCookies([]*network.CookieParam{{ + Name: "rallly-session", + Value: "Fe26.2*1*66a5cae1dd8728fc7be37a1a3c485557606e526b16b472329be78168ad4d48c2*Yb_O9pN2K3APF6LXt9S3zg*IZQ_c5aukJzt-AIW__lL19igVhpFMGH9cK0PyFenF-2ti94BgBsLDf325DB2rsKE*3825906104968*a06f3cfe6ef65db1a30b5177cb767c914ca38c8fc3e2456de89d5bea5641611e*6HNCfDeEzgfeQO88IRJ8TfdG5IDzDQtt6WaoGAg5i98~2", Expires: &expr, + Domain: "rallly.co", + Path: "/", + HTTPOnly: true, + Secure: true, + SameSite: network.CookieSameSiteLax, + }}).WithBrowserContextID(b.BrowserContextID()).Do(ctx) + })) +[] @Ω Gomega should have an error returning mode, then tell pohly +[] @Ω Gomega submatcher description interface and bare-element interface (the former for any sort of matcher that takes a submatcher; the latter specifically for matchers like Consistently etc. that would replace equalMatchersToElements. + + +[] @B JSSelector (is a function that returns one or many nodes) +[] @B ScrollTo etc. +[] @B support for esbuild? or something? consider the auth_login_scripts tests - what might make them better? + +# Long-term Backlog +- VSCode Extension +- Ginkgo WebView +- Suite configuration +- Suite parallelization + - With the special subcase of supporting shared singleton resources diff --git a/integration/_fixtures/interceptor_sleep_fixture/interceptor_fixture_suite_test.go b/integration/_fixtures/interceptor_sleep_fixture/interceptor_fixture_suite_test.go new file mode 100644 index 000000000..61704ce28 --- /dev/null +++ b/integration/_fixtures/interceptor_sleep_fixture/interceptor_fixture_suite_test.go @@ -0,0 +1,25 @@ +package main_test + +import ( + "fmt" + "os" + "os/exec" + "testing" + + . "github.com/onsi/ginkgo/v2" + . "github.com/onsi/gomega" +) + +func TestInterceptorSleepFixture(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "TestInterceptorSleepFixture Suite") +} + +var _ = Describe("Ensuring that ginkgo -p does not hang when output is intercepted", func() { + It("ginkgo -p should not hang on this spec", func() { + fmt.Fprintln(os.Stdout, "Some STDOUT output") + fmt.Fprintln(os.Stderr, "Some STDERR output") + cmd := exec.Command("sleep", "60") + Ω(cmd.Start()).Should(Succeed()) + }) +}) diff --git a/integration/output_interceptor_test.go b/integration/output_interceptor_test.go index 71175efc5..ca93e92e6 100644 --- a/integration/output_interceptor_test.go +++ b/integration/output_interceptor_test.go @@ -2,9 +2,11 @@ package integration_test import ( "os/exec" + "time" . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/onsi/gomega/gbytes" "github.com/onsi/gomega/gexec" ) @@ -47,4 +49,20 @@ var _ = Describe("OutputInterceptor", func() { Ω(report.SpecReports[0].CapturedStdOutErr).Should(Equal("CAPTURED OUTPUT A\nCAPTURED OUTPUT B\n")) }) }) + + Context("ensuring Ginkgo does not hang when a child process does not exit: https://github.com/onsi/ginkgo/issues/1191", func() { + BeforeEach(func() { + fm.MountFixture("interceptor_sleep") + }) + + It("exits without hanging", func() { + sess := startGinkgo(fm.PathTo("interceptor_sleep"), "--no-color", "--procs=2") + Eventually(sess).WithTimeout(time.Second * 15).Should(gexec.Exit(0)) + + Ω(sess).Should(gbytes.Say("Captured StdOut/StdErr Output >>")) + Ω(sess).Should(gbytes.Say("Some STDOUT output")) + Ω(sess).Should(gbytes.Say("Some STDERR output")) + Ω(sess).Should(gbytes.Say("<< Captured StdOut/StdErr Output")) + }) + }) }) diff --git a/internal/output_interceptor_unix.go b/internal/output_interceptor_unix.go index f5ae15b8b..8a237f446 100644 --- a/internal/output_interceptor_unix.go +++ b/internal/output_interceptor_unix.go @@ -26,6 +26,17 @@ func (impl *dupSyscallOutputInterceptorImpl) CreateStdoutStderrClones() (*os.Fil stdoutCloneFD, _ := unix.Dup(1) stderrCloneFD, _ := unix.Dup(2) + // Important, set the fds to FD_CLOEXEC to prevent them leaking into childs + // https://github.com/onsi/ginkgo/issues/1191 + flags, err := unix.FcntlInt(uintptr(stdoutCloneFD), unix.F_GETFD, 0) + if err == nil { + unix.FcntlInt(uintptr(stdoutCloneFD), unix.F_SETFD, flags|unix.FD_CLOEXEC) + } + flags, err = unix.FcntlInt(uintptr(stderrCloneFD), unix.F_GETFD, 0) + if err == nil { + unix.FcntlInt(uintptr(stderrCloneFD), unix.F_SETFD, flags|unix.FD_CLOEXEC) + } + // And then wrap the clone file descriptors in files. // One benefit of this (that we don't use yet) is that we can actually write // to these files to emit output to the console even though we're intercepting output From b56269baa96bf193be23330a595c09a285a840b7 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Wed, 3 May 2023 08:51:22 -0600 Subject: [PATCH 14/23] remove accidental TODO commit --- TODO | 60 ------------------------------------------------------------ 1 file changed, 60 deletions(-) delete mode 100644 TODO diff --git a/TODO b/TODO deleted file mode 100644 index 8a44c4b69..000000000 --- a/TODO +++ /dev/null @@ -1,60 +0,0 @@ -# Backlog -[] @G fix hang with ginkgo -p - https://github.com/onsi/ginkgo/issues/1192 -[] @B biloba needs to support "McDonald's" -[] @G Document order of execution for setup nodes on the same level - https://github.com/onsi/ginkgo/issues/1172 -[] @G fail fast may cause Serial spec or cleanup Node interrupted - https://github.com/onsi/ginkgo/issues/1178 - -# Needs-Prioritization -[] @G Pull JUnit config out of code and into flags/config files - https://github.com/onsi/ginkgo/issues/1115 -[] @G -exec support for `ginkgo run` - https://github.com/onsi/ginkgo/issues/869 -[] @G Add `indent` to gcustom -[] @G HaveField should not panic in FailureMessage if the field is non-existant. It should return a meaningful failure message. -[] @G allow NodeTimeout and GracePeriod to live on containers and propagate down -[] @G Clean up ReportEntry decoding: - func (entry ReportEntry) DecodeValue(p interface{}) error { - // if raw is assignable to p, assign - // else - parse AsJSON - } -[] @B Biloba lets you get all innerHTML and emit it on failure -[] @B equivalent of puppeteer text selector? -[] @B how do we invoke async functions? what does await look like for those? maybe time to actually read? goal: remove the separate muhasibPostLogin function. -[] @B https://github.com/onsi/biloba/issues/2 -[] @B right now polling an element fails if the browser if ollowing redirects. so i'm using Eventually(b.Location) - instead of just Eventually("#el").Should(b.Exist()). I think we need a more robust way to ensure biloba. -[] @B biloba support for gettign "SelectedOption" instead of just "Value" for select inputs (e.g. b.OptionByName(...) instead of value?) -[] @B ginkgo interrupt should not show the whole stacktrace. it's just too much! -[] @B add cookie support - chromedp.Run(b.Context, chromedp.ActionFunc(func(ctx context.Context) error { - return storage.ClearDataForOrigin("*", "all").Do(ctx) - })) - - chromedp.Run(b.Context, chromedp.ActionFunc(func(ctx context.Context) error { - expr := cdp.TimeSinceEpoch(time.Date(2091, 28, 3, 1, 40, 45, 0, time.UTC)) - return storage.SetCookies([]*network.CookieParam{{ - Name: "rallly-session", - Value: "Fe26.2*1*66a5cae1dd8728fc7be37a1a3c485557606e526b16b472329be78168ad4d48c2*Yb_O9pN2K3APF6LXt9S3zg*IZQ_c5aukJzt-AIW__lL19igVhpFMGH9cK0PyFenF-2ti94BgBsLDf325DB2rsKE*3825906104968*a06f3cfe6ef65db1a30b5177cb767c914ca38c8fc3e2456de89d5bea5641611e*6HNCfDeEzgfeQO88IRJ8TfdG5IDzDQtt6WaoGAg5i98~2", Expires: &expr, - Domain: "rallly.co", - Path: "/", - HTTPOnly: true, - Secure: true, - SameSite: network.CookieSameSiteLax, - }}).WithBrowserContextID(b.BrowserContextID()).Do(ctx) - })) -[] @Ω Gomega should have an error returning mode, then tell pohly -[] @Ω Gomega submatcher description interface and bare-element interface (the former for any sort of matcher that takes a submatcher; the latter specifically for matchers like Consistently etc. that would replace equalMatchersToElements. - - -[] @B JSSelector (is a function that returns one or many nodes) -[] @B ScrollTo etc. -[] @B support for esbuild? or something? consider the auth_login_scripts tests - what might make them better? - -# Long-term Backlog -- VSCode Extension -- Ginkgo WebView -- Suite configuration -- Suite parallelization - - With the special subcase of supporting shared singleton resources From 903be81ba5a3f47631e6cb0e7c72c12fe47a6746 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Wed, 3 May 2023 09:02:24 -0600 Subject: [PATCH 15/23] Document run order when multiple setup nodes are at the same nesting level fixes #1172 --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 7f9528d82..2978cfee1 100644 --- a/docs/index.md +++ b/docs/index.md @@ -404,7 +404,7 @@ var _ = Describe("Books", func() { Using container nodes helps clarify the intent behind our suite. The author name specs are now clearly grouped together and we're exploring the behavior of our code in different contexts. Most importantly, we're able to scope additional setup nodes to those contexts to refine our spec setup. -When Ginkgo runs a spec it runs through all the `BeforeEach` closures that appear in that spec's hierarchy from the outer-most to the inner-most. For the `both names` specs, Ginkgo will run the outermost `BeforeEach` closure before the subject node closure. For the `one name` specs, Ginkgo will run the outermost `BeforeEach` closure and then the innermost `BeforeEach` closure which sets `book.Author = "Hugo"`. +When Ginkgo runs a spec it runs through all the `BeforeEach` closures that appear in that spec's hierarchy from the outer-most to the inner-most. If multiple `BeforeEach` nodes appear at the same nesting level they will be run in the order in which they appear in the test file. For the `both names` specs, Ginkgo will run the outermost `BeforeEach` closure before the subject node closure. For the `one name` specs, Ginkgo will run the outermost `BeforeEach` closure and then the innermost `BeforeEach` closure which sets `book.Author = "Hugo"`. Organizing our specs in this way can also help us reason about our spec coverage. What additional contexts are we missing? What edge cases should we worry about? Let's add a few: From 8dea88bb03ed0fa705b8a6b6f5d4999245097e73 Mon Sep 17 00:00:00 2001 From: weizhi Date: Thu, 4 May 2023 04:20:25 +0800 Subject: [PATCH 16/23] fix: fail fast may cause Serial spec or cleanup Node interrupted (#1178) * fix: fail fast may cause Serial spec or cleanup Node interrupted * tighten up edges around abort behavior 1. inter-process aborts should not interrupt cleanup nodes 2. whenever we fetch interrupt status, check and see if an abort has happened. if it has ensure we return the latest, correct, abort state. this allows us to avoid accidentally starting the next spec because the ABORT_POLLING_INTERVAL hasn't fired yet * fix race condition in internal integration suite * fix internal test race condition --------- Co-authored-by: Onsi Fakhouri --- internal/internal_integration/abort_test.go | 78 ++++++++++++++++++- .../internal_integration_suite_test.go | 46 +++++++++++ .../interrupt_handler/interrupt_handler.go | 47 +++++++---- .../interrupt_handler_test.go | 7 +- .../interrupthandler_suite_test.go | 3 + internal/suite.go | 6 ++ internal/test_helpers/fake_reporter.go | 8 ++ 7 files changed, 176 insertions(+), 19 deletions(-) diff --git a/internal/internal_integration/abort_test.go b/internal/internal_integration/abort_test.go index 656b1e995..223b212e0 100644 --- a/internal/internal_integration/abort_test.go +++ b/internal/internal_integration/abort_test.go @@ -1,9 +1,12 @@ package internal_integration_test import ( + "time" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" + "github.com/onsi/ginkgo/v2/internal/interrupt_handler" . "github.com/onsi/ginkgo/v2/internal/test_helpers" "github.com/onsi/ginkgo/v2/types" ) @@ -158,19 +161,92 @@ var _ = Describe("handling test aborts", func() { }) Describe("when running in parallel and a test aborts", func() { + var c chan interface{} BeforeEach(func() { SetUpForParallel(2) + c = make(chan interface{}) }) It("notifies the server of the abort", func() { Ω(client.ShouldAbort()).Should(BeFalse()) - success, _ := RunFixture("aborting in parallel", func() { + success := RunFixtureInParallel("aborting in parallel", func(_ int) { It("A", func() { + <-c Abort("abort") }) + + It("B", func(ctx SpecContext) { + close(c) + select { + case <-ctx.Done(): + rt.Run("dc-done") + case <-time.After(interrupt_handler.ABORT_POLLING_INTERVAL * 2): + rt.Run("dc-after") + } + }) }) Ω(success).Should(BeFalse()) Ω(client.ShouldAbort()).Should(BeTrue()) + + Ω(rt).Should(HaveTracked("dc-done")) //not dc-after + Ω(reporter.Did.Find("A")).Should(HaveAborted("abort")) + Ω(reporter.Did.Find("B")).Should(HaveBeenInterrupted(interrupt_handler.InterruptCauseAbortByOtherProcess)) }) + + It("does not interrupt cleanup nodes", func() { + success := RunFixtureInParallel("aborting in parallel", func(_ int) { + It("A", func() { + <-c + Abort("abort") + }) + + Context("B", func() { + It("B", func() { + }) + + AfterEach(func(ctx SpecContext) { + close(c) + select { + case <-ctx.Done(): + rt.Run("dc-done") + case <-time.After(interrupt_handler.ABORT_POLLING_INTERVAL * 2): + rt.Run("dc-after") + } + }) + }) + }) + Ω(success).Should(BeFalse()) + + Ω(rt).Should(HaveTracked("dc-after")) //not dc-done + Ω(reporter.Did.Find("A")).Should(HaveAborted("abort")) + Ω(reporter.Did.Find("B")).Should(HavePassed()) + }) + + It("does not start serial nodes if an abort occurs", func() { + success := RunFixtureInParallel("aborting in parallel", func(proc int) { + It("A", func() { + time.Sleep(time.Millisecond * 50) + if proc == 2 { + rt.Run("aborting") + Abort("abort") + } + }) + + It("B", func() { + time.Sleep(time.Millisecond * 50) + if proc == 2 { + rt.Run("aborting") + Abort("abort") + } + }) + + It("C", Serial, func() { + rt.Run("C") + }) + }) + Ω(success).Should(BeFalse()) + Ω(rt).Should(HaveTracked("aborting")) //just one aborting and we don't see C + }, MustPassRepeatedly(10)) + }) }) diff --git a/internal/internal_integration/internal_integration_suite_test.go b/internal/internal_integration/internal_integration_suite_test.go index 0966cf448..7264e2f3a 100644 --- a/internal/internal_integration/internal_integration_suite_test.go +++ b/internal/internal_integration/internal_integration_suite_test.go @@ -2,6 +2,7 @@ package internal_integration_test import ( "context" + "fmt" "io" "reflect" "testing" @@ -10,6 +11,7 @@ import ( . "github.com/onsi/ginkgo/v2" "github.com/onsi/ginkgo/v2/internal" "github.com/onsi/ginkgo/v2/internal/global" + "github.com/onsi/ginkgo/v2/internal/interrupt_handler" "github.com/onsi/ginkgo/v2/internal/parallel_support" . "github.com/onsi/ginkgo/v2/internal/test_helpers" "github.com/onsi/ginkgo/v2/types" @@ -18,6 +20,7 @@ import ( ) func TestSuiteTests(t *testing.T) { + interrupt_handler.ABORT_POLLING_INTERVAL = 200 * time.Millisecond format.TruncatedDiff = false RegisterFailHandler(Fail) suiteConfig, _ := GinkgoConfiguration() @@ -81,6 +84,7 @@ func WithSuite(suite *internal.Suite, callback func()) { func SetUpForParallel(parallelTotal int) { conf.ParallelTotal = parallelTotal server, client, exitChannels = SetUpServerAndClient(conf.ParallelTotal) + conf.ParallelHost = server.Address() } @@ -95,6 +99,48 @@ func RunFixture(description string, callback func()) (bool, bool) { return success, hasProgrammaticFocus } +/* +You should call SetUpForParallel() first, then call RunFixtureInParallel() + +this is, at best, an approximation. There are some dsl objects that can be called within a running node (e.g. DeferCleanup) that will not work with RunFixtureInParallel as they will attach to the actual internal_integration suite as opposed to the simulated fixture + +moreover the FakeInterruptHandler is not used - instead a real interrupt handler is created and configured with the client generated by SetUpForParallel. this is to facilitate the testing of cross-process aborts, which was the primary motivator for this method. + +also a noopProgressSignalRegistrar is used to avoid an annoying data race +*/ +func RunFixtureInParallel(description string, callback func(proc int)) bool { + suites := make([]*internal.Suite, conf.ParallelTotal) + finished := make(chan bool, conf.ParallelTotal) + for proc := 1; proc <= conf.ParallelTotal; proc++ { + suites[proc-1] = internal.NewSuite() + WithSuite(suites[proc-1], func() { + callback(proc) + Ω(suites[proc-1].BuildTree()).Should(Succeed()) + }) + } + for proc := 1; proc <= conf.ParallelTotal; proc++ { + proc := proc + c := conf //make a copy + c.ParallelProcess = proc + exit := exitChannels[proc] + suite := suites[proc-1] + go func() { + interruptHandler := interrupt_handler.NewInterruptHandler(client) + defer interruptHandler.Stop() + + success, _ := suite.Run(fmt.Sprintf("%s - %d", description, proc), Label("TopLevelLabel"), "/path/to/suite", failer, reporter, writer, outputInterceptor, interruptHandler, client, noopProgressSignalRegistrar, c) + close(exit) + finished <- success + }() + } + success := true + for proc := 1; proc <= conf.ParallelTotal; proc++ { + success = (<-finished) && success + } + + return success +} + func F(options ...interface{}) { location := cl message := "fail" diff --git a/internal/interrupt_handler/interrupt_handler.go b/internal/interrupt_handler/interrupt_handler.go index ac6f51040..8ed86111f 100644 --- a/internal/interrupt_handler/interrupt_handler.go +++ b/internal/interrupt_handler/interrupt_handler.go @@ -10,7 +10,7 @@ import ( "github.com/onsi/ginkgo/v2/internal/parallel_support" ) -const ABORT_POLLING_INTERVAL = 500 * time.Millisecond +var ABORT_POLLING_INTERVAL = 500 * time.Millisecond type InterruptCause uint @@ -62,13 +62,14 @@ type InterruptHandlerInterface interface { } type InterruptHandler struct { - c chan interface{} - lock *sync.Mutex - level InterruptLevel - cause InterruptCause - client parallel_support.Client - stop chan interface{} - signals []os.Signal + c chan interface{} + lock *sync.Mutex + level InterruptLevel + cause InterruptCause + client parallel_support.Client + stop chan interface{} + signals []os.Signal + requestAbortCheck chan interface{} } func NewInterruptHandler(client parallel_support.Client, signals ...os.Signal) *InterruptHandler { @@ -76,11 +77,12 @@ func NewInterruptHandler(client parallel_support.Client, signals ...os.Signal) * signals = []os.Signal{os.Interrupt, syscall.SIGTERM} } handler := &InterruptHandler{ - c: make(chan interface{}), - lock: &sync.Mutex{}, - stop: make(chan interface{}), - client: client, - signals: signals, + c: make(chan interface{}), + lock: &sync.Mutex{}, + stop: make(chan interface{}), + requestAbortCheck: make(chan interface{}), + client: client, + signals: signals, } handler.registerForInterrupts() return handler @@ -109,6 +111,12 @@ func (handler *InterruptHandler) registerForInterrupts() { pollTicker.Stop() return } + case <-handler.requestAbortCheck: + if handler.client.ShouldAbort() { + close(abortChannel) + pollTicker.Stop() + return + } case <-handler.stop: pollTicker.Stop() return @@ -152,11 +160,18 @@ func (handler *InterruptHandler) registerForInterrupts() { func (handler *InterruptHandler) Status() InterruptStatus { handler.lock.Lock() - defer handler.lock.Unlock() - - return InterruptStatus{ + status := InterruptStatus{ Level: handler.level, Channel: handler.c, Cause: handler.cause, } + handler.lock.Unlock() + + if handler.client != nil && handler.client.ShouldAbort() && !status.Interrupted() { + close(handler.requestAbortCheck) + <-status.Channel + return handler.Status() + } + + return status } diff --git a/internal/interrupt_handler/interrupt_handler_test.go b/internal/interrupt_handler/interrupt_handler_test.go index d93f14b4f..6196440f3 100644 --- a/internal/interrupt_handler/interrupt_handler_test.go +++ b/internal/interrupt_handler/interrupt_handler_test.go @@ -96,8 +96,6 @@ var _ = Describe("InterruptHandler", func() { }) }) - // here - test that abort only triggers once - // here - test interplay with signal Describe("Interrupting when another Ginkgo process has aborted", func() { var client parallel_support.Client BeforeEach(func() { @@ -165,5 +163,10 @@ var _ = Describe("InterruptHandler", func() { Ω(status.Cause).Should(Equal(interrupt_handler.InterruptCauseSignal)) Ω(status.Level).Should(Equal(interrupt_handler.InterruptLevelCleanupAndReport)) }) + + It("doesn't just rely on the ABORT_POLLING_INTERVAL timer to report that the interrupt has happened", func() { + client.PostAbort() + Ω(interruptHandler.Status().Cause).Should(Equal(interrupt_handler.InterruptCauseAbortByOtherProcess)) + }, MustPassRepeatedly(10)) }) }) diff --git a/internal/interrupt_handler/interrupthandler_suite_test.go b/internal/interrupt_handler/interrupthandler_suite_test.go index 555c8bca7..3b539e70b 100644 --- a/internal/interrupt_handler/interrupthandler_suite_test.go +++ b/internal/interrupt_handler/interrupthandler_suite_test.go @@ -2,12 +2,15 @@ package interrupt_handler_test import ( "testing" + "time" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/internal/interrupt_handler" . "github.com/onsi/gomega" ) func TestInterrupthandler(t *testing.T) { + interrupt_handler.ABORT_POLLING_INTERVAL = 50 * time.Millisecond RegisterFailHandler(Fail) RunSpecs(t, "Interrupthandler Suite") } diff --git a/internal/suite.go b/internal/suite.go index a1dbd4c62..60c913d89 100644 --- a/internal/suite.go +++ b/internal/suite.go @@ -937,6 +937,12 @@ func (suite *Suite) runNode(node Node, specDeadline time.Time, text string) (typ gracePeriodChannel = time.After(gracePeriod) case <-interruptStatus.Channel: interruptStatus = suite.interruptHandler.Status() + // ignore interruption from other process if we are cleaning up or reporting + if interruptStatus.Cause == interrupt_handler.InterruptCauseAbortByOtherProcess && + node.NodeType.Is(types.NodeTypesAllowedDuringReportInterrupt|types.NodeTypesAllowedDuringCleanupInterrupt) { + continue + } + deadlineChannel = nil // don't worry about deadlines, time's up now failureTimelineLocation := suite.generateTimelineLocation() diff --git a/internal/test_helpers/fake_reporter.go b/internal/test_helpers/fake_reporter.go index f6d4b71bd..59a3145e6 100644 --- a/internal/test_helpers/fake_reporter.go +++ b/internal/test_helpers/fake_reporter.go @@ -111,18 +111,26 @@ func NewFakeReporter() *FakeReporter { } func (r *FakeReporter) SuiteWillBegin(report types.Report) { + r.lock.Lock() + defer r.lock.Unlock() r.Begin = report } func (r *FakeReporter) WillRun(report types.SpecReport) { + r.lock.Lock() + defer r.lock.Unlock() r.Will = append(r.Will, report) } func (r *FakeReporter) DidRun(report types.SpecReport) { + r.lock.Lock() + defer r.lock.Unlock() r.Did = append(r.Did, report) } func (r *FakeReporter) SuiteDidEnd(report types.Report) { + r.lock.Lock() + defer r.lock.Unlock() r.End = report } func (r *FakeReporter) EmitProgressReport(progressReport types.ProgressReport) { From 909d19387f14c77d47f73878e5d6e63c26fd7afa Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Wed, 3 May 2023 14:24:56 -0600 Subject: [PATCH 17/23] v2.9.4 --- CHANGELOG.md | 11 +++++++++++ types/version.go | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a4b9cc76..d680ea4d9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## 2.9.4 + +### Fixes +- fix hang with ginkgo -p (#1192) [15d4bdc] - this addresses a _long_ standing issue related to Ginkgo hanging when a child process spawned by the test does not exit. + +- fix: fail fast may cause Serial spec or cleanup Node interrupted (#1178) [8dea88b] - prior to this there was a small gap in which specs on other processes might start even if one process has tried to abort the suite. + + +### Maintenance +- Document run order when multiple setup nodes are at the same nesting level [903be81] + ## 2.9.3 ### Features diff --git a/types/version.go b/types/version.go index 38920a439..d452bf9a6 100644 --- a/types/version.go +++ b/types/version.go @@ -1,3 +1,3 @@ package types -const VERSION = "2.9.3" +const VERSION = "2.9.4" From 9e9e3e55e77704674f439e8f32d9bbc8d6472bea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 5 May 2023 09:44:54 +0100 Subject: [PATCH 18/23] Bump golang.org/x/sys from 0.7.0 to 0.8.0 (#1193) Bumps [golang.org/x/sys](https://github.com/golang/sys) from 0.7.0 to 0.8.0. - [Commits](https://github.com/golang/sys/compare/v0.7.0...v0.8.0) --- updated-dependencies: - dependency-name: golang.org/x/sys dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 6ef8236ea..a5bab5961 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 github.com/onsi/gomega v1.27.6 golang.org/x/net v0.9.0 - golang.org/x/sys v0.7.0 + golang.org/x/sys v0.8.0 golang.org/x/tools v0.8.0 ) diff --git a/go.sum b/go.sum index e0e847a1b..8115c9b2a 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU= -golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= From 7fa0b6b29598eca7bab0732f3517ed7a39cb913b Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Fri, 12 May 2023 20:18:46 -0600 Subject: [PATCH 19/23] ensure the correct deterministic sort order is produced when ordered specs are generated by a helper function fixes a subtle bug described in #1198 - the sort order in Ordering.go was not generating a consistent order for Ordered specs generated by helper functions --- internal/internal_integration/ordered_test.go | 51 +++++++++++++++++++ internal/node.go | 9 ++++ internal/node_test.go | 16 ++++++ internal/ordering.go | 51 +++++++++++-------- 4 files changed, 105 insertions(+), 22 deletions(-) diff --git a/internal/internal_integration/ordered_test.go b/internal/internal_integration/ordered_test.go index 0919bd8a0..4b59d3ade 100644 --- a/internal/internal_integration/ordered_test.go +++ b/internal/internal_integration/ordered_test.go @@ -1281,4 +1281,55 @@ var _ = DescribeTable("Ordered Containers", }, "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", HavePassed(), ), + + // Bug reported in #1198 + Entry("bug reported in #1198 - probably due to attempts to ensure deterministic order", true, func() { + Describe("outer", func() { // the only non-Ordered Describe + OrderedRun("a") + OrderedRun("b") + OrderedRun("c") + }) + }, []string{"a1", "a2", "a3", "a4", "a5", "b1", "b2", "b3", "b4", "b5", "c1", "c2", "c3", "c4", "c5"}), ) + +// OrderedRun creates a sequence of tests, all are intended to be Ordered - this is the reproducer provided in #1198 +func OrderedRun(description string) { + Describe(description, Ordered, func() { + It(fmt.Sprint(description, "1"), func() { + rt.Run(description + "1") + }) + + Sub2(description) + Sub3(description) + + Describe("inner", func() { + Sub4(description) + }) + }) +} + +func Sub2(description string) { + It(fmt.Sprint(description, "2"), func() { + rt.Run(description + "2") + }) +} + +func Sub3(description string) { + It(fmt.Sprint(description, "3"), func() { + rt.Run(description + "3") + }) +} + +func Sub4(description string) { + Describe("deeply nested 1", func() { + It(fmt.Sprint(description, "4"), func() { + rt.Run(description + "4") + }) + }) + + Describe("deeply nested 2", func() { + It(fmt.Sprint(description, "5"), func() { + rt.Run(description + "5") + }) + }) +} diff --git a/internal/node.go b/internal/node.go index 0869bffb3..14c7cf54e 100644 --- a/internal/node.go +++ b/internal/node.go @@ -875,6 +875,15 @@ func (n Nodes) FirstNodeMarkedOrdered() Node { return Node{} } +func (n Nodes) IndexOfFirstNodeMarkedOrdered() int { + for i := range n { + if n[i].MarkedOrdered { + return i + } + } + return -1 +} + func (n Nodes) GetMaxFlakeAttempts() int { maxFlakeAttempts := 0 for i := range n { diff --git a/internal/node_test.go b/internal/node_test.go index 588053a76..9a4a99093 100644 --- a/internal/node_test.go +++ b/internal/node_test.go @@ -1579,6 +1579,22 @@ var _ = Describe("Nodes", func() { }) }) + Describe("IndexOfFirstNodeMarkedOrdered", func() { + Context("when there are nodes marked ordered", func() { + It("returns the index of the first one", func() { + nodes := Nodes{N(), N("A", ntCon, Ordered), N("B", ntCon, Ordered), N()} + Ω(nodes.IndexOfFirstNodeMarkedOrdered()).Should(Equal(1)) + }) + }) + + Context("when there is no node marked ordered", func() { + It("returns -1", func() { + nodes := Nodes{N(), N(), N()} + Ω(nodes.IndexOfFirstNodeMarkedOrdered()).Should(Equal(-1)) + }) + }) + }) + Describe("GetMaxFlakeAttempts", func() { Context("when there is no node marked with FlakeAttempts decorator", func() { It("returns 0", func() { diff --git a/internal/ordering.go b/internal/ordering.go index 7ed43c7fd..84eea0a59 100644 --- a/internal/ordering.go +++ b/internal/ordering.go @@ -27,36 +27,43 @@ func (s *SortableSpecs) Swap(i, j int) { s.Indexes[i], s.Indexes[j] = s.Indexes[ func (s *SortableSpecs) Less(i, j int) bool { a, b := s.Specs[s.Indexes[i]], s.Specs[s.Indexes[j]] - firstOrderedA := a.Nodes.FirstNodeMarkedOrdered() - firstOrderedB := b.Nodes.FirstNodeMarkedOrdered() - if firstOrderedA.ID == firstOrderedB.ID && !firstOrderedA.IsZero() { - // strictly preserve order in ordered containers. ID will track this as IDs are generated monotonically - return a.FirstNodeWithType(types.NodeTypeIt).ID < b.FirstNodeWithType(types.NodeTypeIt).ID + aNodes, bNodes := a.Nodes.WithType(types.NodeTypesForContainerAndIt), b.Nodes.WithType(types.NodeTypesForContainerAndIt) + + firstOrderedAIdx, firstOrderedBIdx := aNodes.IndexOfFirstNodeMarkedOrdered(), bNodes.IndexOfFirstNodeMarkedOrdered() + if firstOrderedAIdx > -1 && firstOrderedBIdx > -1 && aNodes[firstOrderedAIdx].ID == bNodes[firstOrderedBIdx].ID { + // strictly preserve order within an ordered containers. ID will track this as IDs are generated monotonically + return aNodes.FirstNodeWithType(types.NodeTypeIt).ID < bNodes.FirstNodeWithType(types.NodeTypeIt).ID + } + + // if either spec is in an ordered container - only use the nodes up to the outermost ordered container + if firstOrderedAIdx > -1 { + aNodes = aNodes[:firstOrderedAIdx+1] + } + if firstOrderedBIdx > -1 { + bNodes = bNodes[:firstOrderedBIdx+1] } - aCLs := a.Nodes.WithType(types.NodeTypesForContainerAndIt).CodeLocations() - bCLs := b.Nodes.WithType(types.NodeTypesForContainerAndIt).CodeLocations() - for i := 0; i < len(aCLs) && i < len(bCLs); i++ { - aCL, bCL := aCLs[i], bCLs[i] - if aCL.FileName < bCL.FileName { - return true - } else if aCL.FileName > bCL.FileName { - return false + for i := 0; i < len(aNodes) && i < len(bNodes); i++ { + aCL, bCL := aNodes[i].CodeLocation, bNodes[i].CodeLocation + if aCL.FileName != bCL.FileName { + return aCL.FileName < bCL.FileName } - if aCL.LineNumber < bCL.LineNumber { - return true - } else if aCL.LineNumber > bCL.LineNumber { - return false + if aCL.LineNumber != bCL.LineNumber { + return aCL.LineNumber < bCL.LineNumber } } // either everything is equal or we have different lengths of CLs - if len(aCLs) < len(bCLs) { - return true - } else if len(aCLs) > len(bCLs) { - return false + if len(aNodes) != len(bNodes) { + return len(aNodes) < len(bNodes) } // ok, now we are sure everything was equal. so we use the spec text to break ties - return a.Text() < b.Text() + for i := 0; i < len(aNodes); i++ { + if aNodes[i].Text != bNodes[i].Text { + return aNodes[i].Text < bNodes[i].Text + } + } + // ok, all those texts were equal. we'll use the ID of the most deeply nested node as a last resort + return aNodes[len(aNodes)-1].ID < bNodes[len(bNodes)-1].ID } type GroupedSpecIndices []SpecIndices From 0013b1a98b1f30b160b3464bb9f48f74526f51ec Mon Sep 17 00:00:00 2001 From: jbpratt Date: Mon, 15 May 2023 05:59:00 -0500 Subject: [PATCH 20/23] fix spelling err in docs (#1199) --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 2978cfee1..0988617da 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3001,7 +3001,7 @@ SynchronizedBeforeSuite(func(ctx SpecContext) []byte { ``` are all valid interruptible signatures. Of course you can specify `context.Context` instead and can mix-and-match interruptibility between the two functions. -Currently the **Reporting** nodes (`ReportAfterEach`, `RepoertAfterSuite`, and `ReportBeforeEach`) cannot be made interruptible and do not accept callbacks that receive a `SpecContext`. This may change in a future release of Ginkgo (in a backward compatible way). +Currently the **Reporting** nodes (`ReportAfterEach`, `ReportAfterSuite`, and `ReportBeforeEach`) cannot be made interruptible and do not accept callbacks that receive a `SpecContext`. This may change in a future release of Ginkgo (in a backward compatible way). As for **Container** nodes, since these run during the Tree Construction Phase they cannot be made interruptible and so do not accept functions that expect a context. And since the `By` annotation is simply syntactic sugar enabling more detailed spec documentation, any callbacks passed to `By` cannot be independently marked as interruptible (you should, instead, use the `context` passed into the node that you're calling `By` from). From 150e3f28a9a4d5a4839c06bb20d4770400569150 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 15 May 2023 11:59:37 +0100 Subject: [PATCH 21/23] Bump golang.org/x/tools from 0.8.0 to 0.9.1 (#1196) Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.8.0 to 0.9.1. - [Release notes](https://github.com/golang/tools/releases) - [Commits](https://github.com/golang/tools/compare/v0.8.0...v0.9.1) --- updated-dependencies: - dependency-name: golang.org/x/tools dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- go.mod | 4 ++-- go.sum | 9 +++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index a5bab5961..4e8dec6b3 100644 --- a/go.mod +++ b/go.mod @@ -7,9 +7,9 @@ require ( github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 github.com/onsi/gomega v1.27.6 - golang.org/x/net v0.9.0 + golang.org/x/net v0.10.0 golang.org/x/sys v0.8.0 - golang.org/x/tools v0.8.0 + golang.org/x/tools v0.9.1 ) require ( diff --git a/go.sum b/go.sum index 8115c9b2a..098d4f6e2 100644 --- a/go.sum +++ b/go.sum @@ -24,15 +24,16 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM= -golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns= +golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk= +golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y= -golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4= +golang.org/x/tools v0.9.1 h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo= +golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= From 9f9d8b9f0393a0fe2b0fa98cbf23475c777c8f4a Mon Sep 17 00:00:00 2001 From: jbpratt Date: Mon, 15 May 2023 07:56:04 -0500 Subject: [PATCH 22/23] fix generators link (#1200) pointing to a 404 due to the extra `ginkgo` --- docs/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index 0988617da..e9fb28c25 100644 --- a/docs/index.md +++ b/docs/index.md @@ -5233,7 +5233,7 @@ with a JSON file The custom data can be accessed like so: `{{ .CustomData.suitename }}` or `{{ range .CustomData.labels }} {{.}} {{ end }}` -Take a look at the [Ginkgo's CLI code](https://github.com/onsi/ginkgo/tree/master/ginkgo/ginkgo/generators) to see what's available in the template. +Take a look at the [Ginkgo's CLI code](https://github.com/onsi/ginkgo/tree/master/ginkgo/generators) to see what's available in the template. ### Creating an Outline of Specs From b59e304f53fb217a4d49c025d092c9ac43b2ad89 Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Mon, 15 May 2023 08:03:02 -0600 Subject: [PATCH 23/23] v2.9.5 --- CHANGELOG.md | 11 +++++++++++ types/version.go | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d680ea4d9..b1811884b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## 2.9.5 + +### Fixes +- ensure the correct deterministic sort order is produced when ordered specs are generated by a helper function [7fa0b6b] + +### Maintenance +- fix generators link (#1200) [9f9d8b9] +- Bump golang.org/x/tools from 0.8.0 to 0.9.1 (#1196) [150e3f2] +- fix spelling err in docs (#1199) [0013b1a] +- Bump golang.org/x/sys from 0.7.0 to 0.8.0 (#1193) [9e9e3e5] + ## 2.9.4 ### Fixes diff --git a/types/version.go b/types/version.go index d452bf9a6..43066341e 100644 --- a/types/version.go +++ b/types/version.go @@ -1,3 +1,3 @@ package types -const VERSION = "2.9.4" +const VERSION = "2.9.5"