Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: onsi/gomega
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.30.0
Choose a base ref
...
head repository: onsi/gomega
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.31.0
Choose a head ref
  • 9 commits
  • 10 files changed
  • 4 contributors

Commits on Nov 29, 2023

  1. Copy the full SHA
    a672c86 View commit details
  2. Bump golang.org/x/net from 0.17.0 to 0.19.0 (#711)

    Bumps [golang.org/x/net](https://github.com/golang/net) from 0.17.0 to 0.19.0.
    - [Commits](golang/net@v0.17.0...v0.19.0)
    
    ---
    updated-dependencies:
    - dependency-name: golang.org/x/net
      dependency-type: direct:production
      update-type: version-update:semver-minor
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Nov 29, 2023
    Copy the full SHA
    df97ecc View commit details
  3. Bump github.com/onsi/ginkgo/v2 from 2.13.0 to 2.13.2 (#713)

    Bumps [github.com/onsi/ginkgo/v2](https://github.com/onsi/ginkgo) from 2.13.0 to 2.13.2.
    - [Release notes](https://github.com/onsi/ginkgo/releases)
    - [Changelog](https://github.com/onsi/ginkgo/blob/master/CHANGELOG.md)
    - [Commits](onsi/ginkgo@v2.13.0...v2.13.2)
    
    ---
    updated-dependencies:
    - dependency-name: github.com/onsi/ginkgo/v2
      dependency-type: direct:production
      update-type: version-update:semver-patch
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Nov 29, 2023
    Copy the full SHA
    54726f0 View commit details

Commits on Dec 18, 2023

  1. Bump github/codeql-action from 2 to 3 (#715)

    Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
    - [Release notes](https://github.com/github/codeql-action/releases)
    - [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
    - [Commits](github/codeql-action@v2...v3)
    
    ---
    updated-dependencies:
    - dependency-name: github/codeql-action
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Dec 18, 2023
    Copy the full SHA
    9836e76 View commit details
  2. Bump actions/setup-go from 4 to 5 (#714)

    Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4 to 5.
    - [Release notes](https://github.com/actions/setup-go/releases)
    - [Commits](actions/setup-go@v4...v5)
    
    ---
    updated-dependencies:
    - dependency-name: actions/setup-go
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Dec 18, 2023
    Copy the full SHA
    f1c8757 View commit details

Commits on Jan 17, 2024

  1. docs: fix typo in example usage "occured" -> "occurred"

    Also change it in some test descriptions where it matters even less.
    watzkuh authored and onsi committed Jan 17, 2024
    Copy the full SHA
    49005fe View commit details
  2. Bump minimum go version

    onsi committed Jan 17, 2024
    Copy the full SHA
    dee1e3c View commit details
  3. Copy the full SHA
    121c37f View commit details
  4. v1.31.0

    onsi committed Jan 17, 2024
    Copy the full SHA
    ba8bba2 View commit details
Showing with 68 additions and 33 deletions.
  1. +3 −3 .github/workflows/codeql-analysis.yml
  2. +2 −2 .github/workflows/test.yml
  3. +14 −0 CHANGELOG.md
  4. +1 −1 docs/index.md
  5. +7 −7 go.mod
  6. +13 −13 go.sum
  7. +1 −1 gomega_dsl.go
  8. +6 −1 internal/async_assertion.go
  9. +20 −4 internal/async_assertion_test.go
  10. +1 −1 matchers.go
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -39,7 +39,7 @@ jobs:

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
@@ -50,7 +50,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
@@ -64,4 +64,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
name: Check modules
steps:
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: '1.20'
- uses: actions/checkout@v4
@@ -19,7 +19,7 @@ jobs:
version: [ '1.20', '1.21' ]
name: Go ${{ matrix.version }}
steps:
- uses: actions/setup-go@v4
- uses: actions/setup-go@v5
with:
go-version: ${{ matrix.version }}
- uses: actions/checkout@v4
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## 1.31.0

### Features
- Async assertions include context cancellation cause if present [121c37f]

### Maintenance
- Bump minimum go version [dee1e3c]
- docs: fix typo in example usage "occured" -> "occurred" [49005fe]
- Bump actions/setup-go from 4 to 5 (#714) [f1c8757]
- Bump github/codeql-action from 2 to 3 (#715) [9836e76]
- Bump github.com/onsi/ginkgo/v2 from 2.13.0 to 2.13.2 (#713) [54726f0]
- Bump golang.org/x/net from 0.17.0 to 0.19.0 (#711) [df97ecc]
- docs: fix `HaveExactElement` typo (#712) [a672c86]

## 1.30.0

### Features
2 changes: 1 addition & 1 deletion docs/index.md
Original file line number Diff line number Diff line change
@@ -161,7 +161,7 @@ Alternatively, such error assertions on multi return value functions can be simp
Similar, asserting that no error occurred is supported, too (where the other return values are allowed to take on any value):

```go
Ω(MultipleReturnValuesFunc()).Error().ShouldNot(HaveOccured())
Ω(MultipleReturnValuesFunc()).Error().ShouldNot(HaveOccurred())
```

### Annotating Assertions
14 changes: 7 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
module github.com/onsi/gomega

go 1.18
go 1.20

require (
github.com/golang/protobuf v1.5.3
github.com/google/go-cmp v0.6.0
github.com/onsi/ginkgo/v2 v2.13.0
golang.org/x/net v0.17.0
github.com/onsi/ginkgo/v2 v2.13.2
golang.org/x/net v0.19.0
gopkg.in/yaml.v3 v3.0.1
)

require (
github.com/go-logr/logr v1.2.4 // indirect
github.com/go-logr/logr v1.3.0 // indirect
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
golang.org/x/sys v0.13.0 // indirect
golang.org/x/text v0.13.0 // indirect
golang.org/x/tools v0.12.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.14.0 // indirect
google.golang.org/protobuf v1.28.0 // indirect
)
26 changes: 13 additions & 13 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY=
github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY=
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=
@@ -17,23 +17,23 @@ github.com/google/go-cmp v0.6.0/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/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4=
github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o=
github.com/onsi/ginkgo/v2 v2.13.2 h1:Bi2gGVkfn6gQcjNjZJVO8Gf0FHzMPf2phUei9tejVMs=
github.com/onsi/ginkgo/v2 v2.13.2/go.mod h1:XStQ8QcGwLyF4HdfcZB8SFOS/MWCgDuXMSBe6zrvLgM=
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=
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/mod v0.12.0 h1:rmsUpXtvNzj340zd98LZ4KntptpfRHwpFOHG188oHXc=
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
golang.org/x/mod v0.13.0 h1:I/DsJXRlw/8l/0c24sM9yb0T4z9liZTduXvdAWYiysY=
golang.org/x/net v0.19.0 h1:zTwKpTd2XuCqf8huc7Fo2iSy+4RHPd10s4KzeTnVr1c=
golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U=
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss=
golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM=
golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc=
golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.14.0 h1:jvNa2pY0M4r62jkRQ6RwEZZyPcymeL9XZMLBbV7U2nc=
golang.org/x/tools v0.14.0/go.mod h1:uYBEerGOWcJyEORxN+Ek8+TT266gXkNlHdJBwexUsBg=
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=
2 changes: 1 addition & 1 deletion gomega_dsl.go
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@ import (
"github.com/onsi/gomega/types"
)

const GOMEGA_VERSION = "1.30.0"
const GOMEGA_VERSION = "1.31.0"

const nilGomegaPanic = `You are trying to make an assertion, but haven't registered Gomega's fail handler.
If you're using Ginkgo then you probably forgot to put your assertion in an It().
7 changes: 6 additions & 1 deletion internal/async_assertion.go
Original file line number Diff line number Diff line change
@@ -553,7 +553,12 @@ func (assertion *AsyncAssertion) match(matcher types.GomegaMatcher, desiredMatch
lock.Unlock()
}
case <-contextDone:
fail("Context was cancelled")
err := context.Cause(assertion.ctx)
if err != nil && err != context.Canceled {
fail(fmt.Sprintf("Context was cancelled (cause: %s)", err))
} else {
fail("Context was cancelled")
}
return false
case <-timeout:
if assertion.asyncType == AsyncAssertionTypeEventually {
24 changes: 20 additions & 4 deletions internal/async_assertion_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package internal_test

import (
"context"
"errors"
"fmt"
"reflect"
@@ -10,7 +11,6 @@ import (

. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
"golang.org/x/net/context"
)

type quickMatcher struct {
@@ -180,7 +180,7 @@ var _ = Describe("Asynchronous Assertions", func() {
Ω(ig.RegisteredHelpers).Should(ContainElement("(*AsyncAssertion).match"))
})

It("renders the matcher's error if an error occured", func() {
It("renders the matcher's error if an error occurred", func() {
ig.G.Eventually(ERR_MATCH).WithTimeout(50 * time.Millisecond).WithPolling(10 * time.Millisecond).Should(SpecMatch())
Ω(ig.FailureMessage).Should(ContainSubstring("Timed out after"))
Ω(ig.FailureMessage).Should(ContainSubstring("The matcher passed to Eventually returned the following error:"))
@@ -275,6 +275,22 @@ var _ = Describe("Asynchronous Assertions", func() {
Ω(ig.FailureMessage).Should(ContainSubstring("Context was cancelled after"))
Ω(ig.FailureMessage).Should(ContainSubstring("There is no failure as the matcher passed to Consistently has not yet failed"))
})

It("includes the cancel cause if provided", func() {
ctx, cancel := context.WithCancelCause(context.Background())
counter := 0
ig.G.Eventually(func() string {
counter++
if counter == 2 {
cancel(fmt.Errorf("kaboom"))
} else if counter == 10 {
return MATCH
}
return NO_MATCH
}, time.Hour, ctx).Should(SpecMatch())
Ω(ig.FailureMessage).Should(ContainSubstring("Context was cancelled (cause: kaboom) after"))
Ω(ig.FailureMessage).Should(ContainSubstring("positive: no match"))
})
})

Context("when the passed-in context is a Ginkgo SpecContext that can take a progress reporter attachment", func() {
@@ -443,7 +459,7 @@ var _ = Describe("Asynchronous Assertions", func() {
Ω(ig.RegisteredHelpers).Should(ContainElement("(*AsyncAssertion).match"))
})

It("renders the matcher's error if an error occured", func() {
It("renders the matcher's error if an error occurred", func() {
ig.G.Consistently(ERR_MATCH).Should(SpecMatch())
Ω(ig.FailureMessage).Should(ContainSubstring("Failed after"))
Ω(ig.FailureMessage).Should(ContainSubstring("The matcher passed to Consistently returned the following error:"))
@@ -1575,7 +1591,7 @@ sprocket:
})

When("the actual error is because there was an assertion failure in the function, and there are return values", func() {
It("emits a clear message about the error having occured", func() {
It("emits a clear message about the error having occurred", func() {
_, file, line, _ := runtime.Caller(0)
ig.G.Eventually(func(g Gomega) int {
g.Expect(true).To(BeFalse())
2 changes: 1 addition & 1 deletion matchers.go
Original file line number Diff line number Diff line change
@@ -394,7 +394,7 @@ func ConsistOf(elements ...interface{}) types.GomegaMatcher {
}
}

// HaveExactElemets succeeds if actual contains elements that precisely match the elemets passed into the matcher. The ordering of the elements does matter.
// HaveExactElements succeeds if actual contains elements that precisely match the elemets passed into the matcher. The ordering of the elements does matter.
// By default HaveExactElements() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples:
//
// Expect([]string{"Foo", "FooBar"}).Should(HaveExactElements("Foo", "FooBar"))