New Upstream Release - golang-github-frankban-quicktest

Ready changes

Summary

Merged new upstream version: 1.14.5 (was: 1.14.4).

Diff

diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index 224814c..3d137a5 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -6,11 +6,11 @@ jobs:
     name: Build and Test
     strategy:
       matrix:
-        go: ['1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.19']
+        go: ['1.13', '1.14', '1.15', '1.16', '1.17', '1.18', '1.19', '1.20']
     runs-on: ubuntu-latest
     steps:
     - uses: actions/checkout@v3
-    - uses: actions/setup-go@v3
+    - uses: actions/setup-go@v4
       with:
         go-version: ${{ matrix.go }}
     - uses: actions/cache@v3
diff --git a/README.md b/README.md
index 9bdf7f8..2c14a0f 100644
--- a/README.md
+++ b/README.md
@@ -206,6 +206,7 @@ the provided regular expression.
 For instance:
 
     c.Assert(err, qt.ErrorMatches, `bad wolf .*`)
+    c.Assert(err, qt.ErrorMatches, regexp.MustCompile("bad wolf .*"))
 
 
 ### HasLen
@@ -301,6 +302,7 @@ For instance:
 
     c.Assert("these are the voyages", qt.Matches, `these are .*`)
     c.Assert(net.ParseIP("1.2.3.4"), qt.Matches, `1.*`)
+    c.Assert("line 1\nline 2", qt.Matches, regexp.MustCompile(`line \d\nline \d`))
 
 
 ### Not
@@ -321,6 +323,7 @@ the provided regular expression.
 For instance:
 
     c.Assert(func() {panic("bad wolf ...")}, qt.PanicMatches, `bad wolf .*`)
+    c.Assert(func() {panic("bad wolf ...")}, qt.PanicMatches, regexp.MustCompile(`bad wolf .*`))
 
 
 ### Satisfies
diff --git a/checker.go b/checker.go
index 77184ba..401437a 100644
--- a/checker.go
+++ b/checker.go
@@ -131,7 +131,7 @@ func (c *cmpEqualsChecker) Check(got interface{}, args []interface{}, note func(
 		// structs with unexported fields and neither AllowUnexported nor
 		// cmpopts.IgnoreUnexported are provided.
 		if r := recover(); r != nil {
-			err = fmt.Errorf("%s", r)
+			err = BadCheckf("%s", r)
 		}
 	}()
 	want := args[0]
@@ -170,6 +170,7 @@ var ContentEquals = CmpEquals(cmpopts.SortSlices(func(x, y interface{}) bool {
 //
 //	c.Assert("these are the voyages", qt.Matches, "these are .*")
 //	c.Assert(net.ParseIP("1.2.3.4"), qt.Matches, "1.*")
+//	c.Assert("my multi-line\nnumber", qt.Matches, regexp.MustCompile(`my multi-line\n(string|number)`))
 var Matches Checker = &matchesChecker{
 	argNames: []string{"got value", "regexp"},
 }
@@ -210,6 +211,7 @@ func checkFirstArgIsError(got interface{}, note func(key string, value interface
 // For instance:
 //
 //	c.Assert(err, qt.ErrorMatches, "bad wolf .*")
+//	c.Assert(err, qt.ErrorMatches, regexp.MustCompile("bad wolf .*"))
 var ErrorMatches Checker = &errorMatchesChecker{
 	argNames: []string{"got error", "regexp"},
 }
@@ -235,6 +237,7 @@ func (c *errorMatchesChecker) Check(got interface{}, args []interface{}, note fu
 // For instance:
 //
 //	c.Assert(func() {panic("bad wolf ...")}, qt.PanicMatches, "bad wolf .*")
+//	c.Assert(func() {panic("bad wolf ...")}, qt.PanicMatches, regexp.MustCompile(`bad wolf .*`))
 var PanicMatches Checker = &panicMatchesChecker{
 	argNames: []string{"function", "regexp"},
 }
@@ -433,8 +436,6 @@ type satisfiesChecker struct {
 func (c *satisfiesChecker) Check(got interface{}, args []interface{}, note func(key string, value interface{})) (err error) {
 	// Original code at
 	// <https://github.com/juju/testing/blob/master/checkers/bool.go>.
-	// Copyright 2011 Canonical Ltd.
-	// Licensed under the LGPLv3, see LICENSE file for details.
 	predicate := args[0]
 	f := reflect.ValueOf(predicate)
 	ftype := f.Type()
@@ -766,6 +767,12 @@ func (a argNames) ArgNames() []string {
 
 // match checks that the given error message matches the given pattern.
 func match(got string, pattern interface{}, msg string, note func(key string, value interface{})) error {
+	if actualRegex, ok := pattern.(*regexp.Regexp); ok {
+		if actualRegex.MatchString(got) {
+			return nil
+		}
+		return errors.New(msg)
+	}
 	regex, ok := pattern.(string)
 	if !ok {
 		note("regexp", pattern)
diff --git a/checker_test.go b/checker_test.go
index d60995a..cb7543c 100644
--- a/checker_test.go
+++ b/checker_test.go
@@ -7,6 +7,7 @@ import (
 	"encoding/json"
 	"errors"
 	"fmt"
+	"regexp"
 	"strings"
 	"testing"
 	"time"
@@ -537,13 +538,15 @@ want:
 	},
 	expectedCheckFailure: `
 error:
-  cannot handle unexported field at root.answer:
+  bad check: cannot handle unexported field at root.answer:
+  	"github.com/frankban/quicktest_test".(struct { answer int })
+  consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported
+`,
+	expectedNegateFailure: `
+error:
+  bad check: cannot handle unexported field at root.answer:
   	"github.com/frankban/quicktest_test".(struct { answer int })
   consider using a custom Comparer; if you control the implementation of type, you can also consider using an Exporter, AllowUnexported, or cmpopts.IgnoreUnexported
-got:
-  struct { answer int }{answer:42}
-want:
-  <same as "got">
 `,
 }, {
 	about:   "CmpEquals: structs with unexported fields ignored",
@@ -937,6 +940,45 @@ got value:
 regexp:
   "these are the .*"
 `,
+}, {
+	about:   "Matches: match with pre-compiled regexp",
+	checker: qt.Matches,
+	got:     bytes.NewBufferString("resistance is futile"),
+	args:    []interface{}{regexp.MustCompile("resistance is (futile|useful)")},
+	expectedNegateFailure: `
+error:
+  unexpected success
+got value:
+  s"resistance is futile"
+regexp:
+  s"resistance is (futile|useful)"
+`,
+}, {
+	about:   "Matches: mismatch with pre-compiled regexp",
+	checker: qt.Matches,
+	got:     bytes.NewBufferString("resistance is cool"),
+	args:    []interface{}{regexp.MustCompile("resistance is (futile|useful)")},
+	expectedCheckFailure: `
+error:
+  value.String() does not match regexp
+got value:
+  s"resistance is cool"
+regexp:
+  s"resistance is (futile|useful)"
+`,
+}, {
+	about:   "Matches: match with pre-compiled multi-line regexp",
+	checker: qt.Matches,
+	got:     bytes.NewBufferString("line 1\nline 2"),
+	args:    []interface{}{regexp.MustCompile(`line \d\nline \d`)},
+	expectedNegateFailure: `
+error:
+  unexpected success
+got value:
+  s"line 1\nline 2"
+regexp:
+  s"line \\d\\nline \\d"
+`,
 }, {
 	about:   "Matches: match with stringer",
 	checker: qt.Matches,
@@ -1271,6 +1313,49 @@ got args:
 want args:
   regexp
 `,
+}, {
+	about:   "ErrorMatches: match with pre-compiled regexp",
+	checker: qt.ErrorMatches,
+	got:     errBadWolf,
+	args:    []interface{}{regexp.MustCompile("bad (wolf|dog)")},
+	expectedNegateFailure: `
+error:
+  unexpected success
+got error:
+  bad wolf
+    file:line
+regexp:
+  s"bad (wolf|dog)"
+`,
+}, {
+	about:   "ErrorMatches: match with pre-compiled multi-line regexp",
+	checker: qt.ErrorMatches,
+	got:     errBadWolfMultiLine,
+	args:    []interface{}{regexp.MustCompile(`bad (wolf|dog)\nfaulty (logic|statement)`)},
+	expectedNegateFailure: `
+error:
+  unexpected success
+got error:
+  bad wolf
+  faulty logic
+    file:line
+regexp:
+  s"bad (wolf|dog)\\nfaulty (logic|statement)"
+`,
+}, {
+	about:   "ErrorMatches: mismatch with pre-compiled regexp",
+	checker: qt.ErrorMatches,
+	got:     errBadWolf,
+	args:    []interface{}{regexp.MustCompile("good (wolf|dog)")},
+	expectedCheckFailure: `
+error:
+  error does not match regexp
+got error:
+  bad wolf
+    file:line
+regexp:
+  s"good (wolf|dog)"
+`,
 }, {
 	about:   "PanicMatches: perfect match",
 	checker: qt.PanicMatches,
@@ -1388,6 +1473,51 @@ panic value:
 regexp:
   nil
 `,
+}, {
+	about:   "PanicMatches: match with pre-compiled regexp",
+	checker: qt.PanicMatches,
+	got:     func() { panic("error: bad wolf") },
+	args:    []interface{}{regexp.MustCompile("error: bad (wolf|dog)")},
+	expectedNegateFailure: `
+error:
+  unexpected success
+panic value:
+  "error: bad wolf"
+function:
+  func() {...}
+regexp:
+  s"error: bad (wolf|dog)"
+`,
+}, {
+	about:   "PanicMatches: match with pre-compiled multi-line regexp",
+	checker: qt.PanicMatches,
+	got:     func() { panic("error: bad wolf\nfaulty logic") },
+	args:    []interface{}{regexp.MustCompile(`error: bad (wolf|dog)\nfaulty (logic|statement)`)},
+	expectedNegateFailure: `
+error:
+  unexpected success
+panic value:
+  "error: bad wolf\nfaulty logic"
+function:
+  func() {...}
+regexp:
+  s"error: bad (wolf|dog)\\nfaulty (logic|statement)"
+`,
+}, {
+	about:   "PanicMatches: mismatch with pre-compiled regexp",
+	checker: qt.PanicMatches,
+	got:     func() { panic("error: bad wolf") },
+	args:    []interface{}{regexp.MustCompile("good (wolf|dog)")},
+	expectedCheckFailure: `
+error:
+  panic value does not match regexp
+panic value:
+  "error: bad wolf"
+function:
+  func() {...}
+regexp:
+  s"good (wolf|dog)"
+`,
 }, {
 	about:   "PanicMatches: not a function",
 	checker: qt.PanicMatches,
diff --git a/debian/changelog b/debian/changelog
index fcee29f..93d97cf 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+golang-github-frankban-quicktest (1.14.5-1) UNRELEASED; urgency=low
+
+  * New upstream release.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Sat, 13 May 2023 20:12:48 -0000
+
 golang-github-frankban-quicktest (1.14.4-1) unstable; urgency=medium
 
   * New upstream version 1.14.4
diff --git a/error_test.go b/error_test.go
index 771c159..eba25d4 100644
--- a/error_test.go
+++ b/error_test.go
@@ -30,6 +30,11 @@ var errBadWolf = &errTest{
 	formatted: true,
 }
 
+var errBadWolfMultiLine = &errTest{
+	msg:       "bad wolf\nfaulty logic",
+	formatted: true,
+}
+
 // errTest is an error type used in tests.
 type errTest struct {
 	msg       string

More details

Full run details

Historical runs