dependencies: gomega v1.30.0 + ginkgo v2.13.2

The new gomega.BeTrueBecause and gomega.BeFalseBecause are going to be useful
for https://github.com/kubernetes/kubernetes/issues/105678.
This commit is contained in:
Patrick Ohly
2023-12-19 16:16:02 +01:00
parent d647d19f6a
commit c8f9ebfb72
448 changed files with 1323 additions and 916 deletions

View File

@@ -1,3 +1,21 @@
## 2.13.2
### Fixes
- Fix file handler leak (#1309) [e2e81c8]
- Avoid allocations with `(*regexp.Regexp).MatchString` (#1302) [3b2a2a7]
## 2.13.1
### Fixes
- # 1296 fix(precompiled test guite): exec bit check omitted on Windows (#1301) [26eea01]
### Maintenance
- Bump github.com/go-logr/logr from 1.2.4 to 1.3.0 (#1291) [7161a9d]
- Bump golang.org/x/sys from 0.13.0 to 0.14.0 (#1295) [7fc7b10]
- Bump golang.org/x/tools from 0.12.0 to 0.14.0 (#1282) [74bbd65]
- Bump github.com/onsi/gomega from 1.27.10 to 1.29.0 (#1290) [9373633]
- Bump golang.org/x/net in /integration/_fixtures/version_mismatch_fixture (#1286) [6e3cf65]
## 2.13.0
### Features

View File

@@ -7,6 +7,7 @@ import (
"path"
"path/filepath"
"regexp"
"runtime"
"strings"
"github.com/onsi/ginkgo/v2/types"
@@ -192,7 +193,7 @@ func precompiledTestSuite(path string) (TestSuite, error) {
return TestSuite{}, errors.New("this is not a .test binary")
}
if filepath.Ext(path) == ".test" && info.Mode()&0111 == 0 {
if filepath.Ext(path) == ".test" && runtime.GOOS != "windows" && info.Mode()&0111 == 0 {
return TestSuite{}, errors.New("this is not executable")
}
@@ -225,7 +226,7 @@ func suitesInDir(dir string, recurse bool) TestSuites {
files, _ := os.ReadDir(dir)
re := regexp.MustCompile(`^[^._].*_test\.go$`)
for _, file := range files {
if !file.IsDir() && re.Match([]byte(file.Name())) {
if !file.IsDir() && re.MatchString(file.Name()) {
suite := TestSuite{
Path: relPath(dir),
PackageName: packageNameForSuite(dir),
@@ -240,7 +241,7 @@ func suitesInDir(dir string, recurse bool) TestSuites {
if recurse {
re = regexp.MustCompile(`^[._]`)
for _, file := range files {
if file.IsDir() && !re.Match([]byte(file.Name())) {
if file.IsDir() && !re.MatchString(file.Name()) {
suites = append(suites, suitesInDir(dir+"/"+file.Name(), recurse)...)
}
}
@@ -271,7 +272,7 @@ func filesHaveGinkgoSuite(dir string, files []os.DirEntry) bool {
reGinkgo := regexp.MustCompile(`package ginkgo|\/ginkgo"|\/ginkgo\/v2"|\/ginkgo\/v2/dsl/`)
for _, file := range files {
if !file.IsDir() && reTestFile.Match([]byte(file.Name())) {
if !file.IsDir() && reTestFile.MatchString(file.Name()) {
contents, _ := os.ReadFile(dir + "/" + file.Name())
if reGinkgo.Match(contents) {
return true

View File

@@ -78,7 +78,7 @@ func (d Dependencies) resolveAndAdd(deps []string, depth int) {
if err != nil {
continue
}
if !pkg.Goroot && (!ginkgoAndGomegaFilter.Match([]byte(pkg.Dir)) || ginkgoIntegrationTestFilter.Match([]byte(pkg.Dir))) {
if !pkg.Goroot && (!ginkgoAndGomegaFilter.MatchString(pkg.Dir) || ginkgoIntegrationTestFilter.MatchString(pkg.Dir)) {
d.addDepIfNotPresent(pkg.Dir, depth)
}
}

View File

@@ -79,7 +79,7 @@ func (p *PackageHash) computeHashes() (codeHash string, codeModifiedTime time.Ti
continue
}
if goTestRegExp.Match([]byte(info.Name())) {
if goTestRegExp.MatchString(info.Name()) {
testHash += p.hashForFileInfo(info)
if info.ModTime().After(testModifiedTime) {
testModifiedTime = info.ModTime()
@@ -87,7 +87,7 @@ func (p *PackageHash) computeHashes() (codeHash string, codeModifiedTime time.Ti
continue
}
if p.watchRegExp.Match([]byte(info.Name())) {
if p.watchRegExp.MatchString(info.Name()) {
codeHash += p.hashForFileInfo(info)
if info.ModTime().After(codeModifiedTime) {
codeModifiedTime = info.ModTime()

View File

@@ -18,6 +18,7 @@ func GenerateJSONReport(report types.Report, destination string) error {
if err != nil {
return err
}
defer f.Close()
enc := json.NewEncoder(f)
enc.SetIndent("", " ")
err = enc.Encode([]types.Report{
@@ -26,7 +27,7 @@ func GenerateJSONReport(report types.Report, destination string) error {
if err != nil {
return err
}
return f.Close()
return nil
}
// MergeJSONReports produces a single JSON-formatted report at the passed in destination by merging the JSON-formatted reports provided in sources
@@ -57,11 +58,12 @@ func MergeAndCleanupJSONReports(sources []string, destination string) ([]string,
if err != nil {
return messages, err
}
defer f.Close()
enc := json.NewEncoder(f)
enc.SetIndent("", " ")
err = enc.Encode(allReports)
if err != nil {
return messages, err
}
return messages, f.Close()
return messages, nil
}

View File

@@ -149,7 +149,7 @@ func PruneStack(fullStackTrace string, skip int) string {
re := regexp.MustCompile(`\/ginkgo\/|\/pkg\/testing\/|\/pkg\/runtime\/`)
for i := 0; i < len(stack)/2; i++ {
// We filter out based on the source code file name.
if !re.Match([]byte(stack[i*2+1])) {
if !re.MatchString(stack[i*2+1]) {
prunedStack = append(prunedStack, stack[i*2])
prunedStack = append(prunedStack, stack[i*2+1])
}

View File

@@ -1,3 +1,3 @@
package types
const VERSION = "2.13.0"
const VERSION = "2.13.2"

View File

@@ -1,3 +1,12 @@
## 1.30.0
### Features
- BeTrueBecause and BeFalseBecause allow for better failure messages [4da4c7f]
### Maintenance
- Bump actions/checkout from 3 to 4 (#694) [6ca6e97]
- doc: fix type on gleak go doc [f1b8343]
## 1.29.0
### Features

View File

@@ -22,7 +22,7 @@ import (
"github.com/onsi/gomega/types"
)
const GOMEGA_VERSION = "1.29.0"
const GOMEGA_VERSION = "1.30.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().

View File

@@ -1,6 +1,7 @@
package gomega
import (
"fmt"
"time"
"github.com/google/go-cmp/cmp"
@@ -52,15 +53,31 @@ func BeNil() types.GomegaMatcher {
}
// BeTrue succeeds if actual is true
//
// In general, it's better to use `BeTrueBecause(reason)` to provide a more useful error message if a true check fails.
func BeTrue() types.GomegaMatcher {
return &matchers.BeTrueMatcher{}
}
// BeFalse succeeds if actual is false
//
// In general, it's better to use `BeFalseBecause(reason)` to provide a more useful error message if a false check fails.
func BeFalse() types.GomegaMatcher {
return &matchers.BeFalseMatcher{}
}
// BeTrueBecause succeeds if actual is true and displays the provided reason if it is false
// fmt.Sprintf is used to render the reason
func BeTrueBecause(format string, args ...any) types.GomegaMatcher {
return &matchers.BeTrueMatcher{Reason: fmt.Sprintf(format, args...)}
}
// BeFalseBecause succeeds if actual is false and displays the provided reason if it is true.
// fmt.Sprintf is used to render the reason
func BeFalseBecause(format string, args ...any) types.GomegaMatcher {
return &matchers.BeFalseMatcher{Reason: fmt.Sprintf(format, args...)}
}
// HaveOccurred succeeds if actual is a non-nil error
// The typical Go error checking pattern looks like:
//

View File

@@ -9,6 +9,7 @@ import (
)
type BeFalseMatcher struct {
Reason string
}
func (matcher *BeFalseMatcher) Match(actual interface{}) (success bool, err error) {
@@ -20,9 +21,17 @@ func (matcher *BeFalseMatcher) Match(actual interface{}) (success bool, err erro
}
func (matcher *BeFalseMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be false")
if matcher.Reason == "" {
return format.Message(actual, "to be false")
} else {
return matcher.Reason
}
}
func (matcher *BeFalseMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to be false")
if matcher.Reason == "" {
return format.Message(actual, "not to be false")
} else {
return fmt.Sprintf(`Expected not false but got false\nNegation of "%s" failed`, matcher.Reason)
}
}

View File

@@ -9,6 +9,7 @@ import (
)
type BeTrueMatcher struct {
Reason string
}
func (matcher *BeTrueMatcher) Match(actual interface{}) (success bool, err error) {
@@ -20,9 +21,17 @@ func (matcher *BeTrueMatcher) Match(actual interface{}) (success bool, err error
}
func (matcher *BeTrueMatcher) FailureMessage(actual interface{}) (message string) {
return format.Message(actual, "to be true")
if matcher.Reason == "" {
return format.Message(actual, "to be true")
} else {
return matcher.Reason
}
}
func (matcher *BeTrueMatcher) NegatedFailureMessage(actual interface{}) (message string) {
return format.Message(actual, "not to be true")
if matcher.Reason == "" {
return format.Message(actual, "not to be true")
} else {
return fmt.Sprintf(`Expected not true but got true\nNegation of "%s" failed`, matcher.Reason)
}
}