Skip to content

Commit

Permalink
Merge pull request #674 from srabraham/master
Browse files Browse the repository at this point in the history
upgrade deps, update to go 1.18
  • Loading branch information
riannucci committed Apr 7, 2023
2 parents a607973 + 6367023 commit 4aefd2b
Show file tree
Hide file tree
Showing 10 changed files with 68 additions and 62 deletions.
24 changes: 12 additions & 12 deletions convey/context.go
Expand Up @@ -9,14 +9,14 @@ import (

type conveyErr struct {
fmt string
params []interface{}
params []any
}

func (e *conveyErr) Error() string {
return fmt.Sprintf(e.fmt, e.params...)
}

func conveyPanic(fmt string, params ...interface{}) {
func conveyPanic(fmt string, params ...any) {
panic(&conveyErr{fmt, params})
}

Expand Down Expand Up @@ -85,7 +85,7 @@ type context struct {
// rootConvey is the main entry point to a test suite. This is called when
// there's no context in the stack already, and items must contain a `t` object,
// or this panics.
func rootConvey(items ...interface{}) {
func rootConvey(items ...any) {
entry := discover(items)

if entry.Test == nil {
Expand Down Expand Up @@ -117,15 +117,15 @@ func rootConvey(items ...interface{}) {

//////////////////////////////////// Methods ////////////////////////////////////

func (ctx *context) SkipConvey(items ...interface{}) {
func (ctx *context) SkipConvey(items ...any) {
ctx.Convey(items, skipConvey)
}

func (ctx *context) FocusConvey(items ...interface{}) {
func (ctx *context) FocusConvey(items ...any) {
ctx.Convey(items, focusConvey)
}

func (ctx *context) Convey(items ...interface{}) {
func (ctx *context) Convey(items ...any) {
entry := discover(items)

// we're a branch, or leaf (on the wind)
Expand Down Expand Up @@ -168,19 +168,19 @@ func (ctx *context) Convey(items ...interface{}) {
}
}

func (ctx *context) SkipSo(stuff ...interface{}) {
func (ctx *context) SkipSo(stuff ...any) {
ctx.assertionReport(reporting.NewSkipReport())
}

func (ctx *context) So(actual interface{}, assert Assertion, expected ...interface{}) {
func (ctx *context) So(actual any, assert Assertion, expected ...any) {
if result := assert(actual, expected...); result == assertionSuccess {
ctx.assertionReport(reporting.NewSuccessReport())
} else {
ctx.assertionReport(reporting.NewFailureReport(result, ctx.shouldShowStack()))
}
}

func (ctx *context) SoMsg(msg string, actual interface{}, assert Assertion, expected ...interface{}) {
func (ctx *context) SoMsg(msg string, actual any, assert Assertion, expected ...any) {
if result := assert(actual, expected...); result == assertionSuccess {
ctx.assertionReport(reporting.NewSuccessReport())
return
Expand All @@ -196,17 +196,17 @@ func (ctx *context) Reset(action func()) {
ctx.resets = append(ctx.resets, action)
}

func (ctx *context) Print(items ...interface{}) (int, error) {
func (ctx *context) Print(items ...any) (int, error) {
fmt.Fprint(ctx.reporter, items...)
return fmt.Print(items...)
}

func (ctx *context) Println(items ...interface{}) (int, error) {
func (ctx *context) Println(items ...any) (int, error) {
fmt.Fprintln(ctx.reporter, items...)
return fmt.Println(items...)
}

func (ctx *context) Printf(format string, items ...interface{}) (int, error) {
func (ctx *context) Printf(format string, items ...any) (int, error) {
fmt.Fprintf(ctx.reporter, format, items...)
return fmt.Printf(format, items...)
}
Expand Down
16 changes: 8 additions & 8 deletions convey/discovery.go
Expand Up @@ -34,7 +34,7 @@ func newSuite(situation string, failureMode FailureMode, stackMode StackMode, f
return ret
}

func discover(items []interface{}) *suite {
func discover(items []any) *suite {
name, items := parseName(items)
test, items := parseGoTest(items)
failure, items := parseFailureMode(items)
Expand All @@ -48,38 +48,38 @@ func discover(items []interface{}) *suite {

return newSuite(name, failure, stack, action, test, specifier)
}
func item(items []interface{}) interface{} {
func item(items []any) any {
if len(items) == 0 {
conveyPanic(parseError)
}
return items[0]
}
func parseName(items []interface{}) (string, []interface{}) {
func parseName(items []any) (string, []any) {
if name, parsed := item(items).(string); parsed {
return name, items[1:]
}
conveyPanic(parseError)
panic("never get here")
}
func parseGoTest(items []interface{}) (t, []interface{}) {
func parseGoTest(items []any) (t, []any) {
if test, parsed := item(items).(t); parsed {
return test, items[1:]
}
return nil, items
}
func parseFailureMode(items []interface{}) (FailureMode, []interface{}) {
func parseFailureMode(items []any) (FailureMode, []any) {
if mode, parsed := item(items).(FailureMode); parsed {
return mode, items[1:]
}
return FailureInherits, items
}
func parseStackMode(items []interface{}) (StackMode, []interface{}) {
func parseStackMode(items []any) (StackMode, []any) {
if mode, parsed := item(items).(StackMode); parsed {
return mode, items[1:]
}
return StackInherits, items
}
func parseAction(items []interface{}) (func(C), []interface{}) {
func parseAction(items []any) (func(C), []any) {
switch x := item(items).(type) {
case nil:
return nil, items[1:]
Expand All @@ -91,7 +91,7 @@ func parseAction(items []interface{}) (func(C), []interface{}) {
conveyPanic(parseError)
panic("never get here")
}
func parseSpecifier(items []interface{}) (actionSpecifier, []interface{}) {
func parseSpecifier(items []any) (actionSpecifier, []any) {
if len(items) == 0 {
return noSpecifier, items
}
Expand Down
38 changes: 19 additions & 19 deletions convey/doc.go
Expand Up @@ -19,19 +19,19 @@ import "github.com/smartystreets/goconvey/convey/reporting"
// All methods in this context behave identically to the global functions of the
// same name in this package.
type C interface {
Convey(items ...interface{})
SkipConvey(items ...interface{})
FocusConvey(items ...interface{})
Convey(items ...any)
SkipConvey(items ...any)
FocusConvey(items ...any)

So(actual interface{}, assert Assertion, expected ...interface{})
SoMsg(msg string, actual interface{}, assert Assertion, expected ...interface{})
SkipSo(stuff ...interface{})
So(actual any, assert Assertion, expected ...any)
SoMsg(msg string, actual any, assert Assertion, expected ...any)
SkipSo(stuff ...any)

Reset(action func())

Println(items ...interface{}) (int, error)
Print(items ...interface{}) (int, error)
Printf(format string, items ...interface{}) (int, error)
Println(items ...any) (int, error)
Print(items ...any) (int, error)
Printf(format string, items ...any) (int, error)
}

// Convey is the method intended for use when declaring the scopes of
Expand Down Expand Up @@ -71,7 +71,7 @@ type C interface {
// Convey(description string, mode FailureMode, action func())
//
// See the examples package for, well, examples.
func Convey(items ...interface{}) {
func Convey(items ...any) {
if ctx := getCurrentContext(); ctx == nil {
rootConvey(items...)
} else {
Expand All @@ -82,7 +82,7 @@ func Convey(items ...interface{}) {
// SkipConvey is analogous to Convey except that the scope is not executed
// (which means that child scopes defined within this scope are not run either).
// The reporter will be notified that this step was skipped.
func SkipConvey(items ...interface{}) {
func SkipConvey(items ...any) {
Convey(append(items, skipConvey)...)
}

Expand All @@ -93,7 +93,7 @@ func SkipConvey(items ...interface{}) {
// repeatedly as you can disable all but one of that function
// without swaths of `SkipConvey` calls, just a targeted chain of calls
// to FocusConvey.
func FocusConvey(items ...interface{}) {
func FocusConvey(items ...any) {
Convey(append(items, focusConvey)...)
}

Expand All @@ -109,7 +109,7 @@ func Reset(action func()) {
// method can handle. Any future or custom assertions should conform to this
// method signature. The return value should be an empty string if the assertion
// passes and a well-formed failure message if not.
type Assertion func(actual interface{}, expected ...interface{}) string
type Assertion func(actual any, expected ...any) string

const assertionSuccess = ""

Expand All @@ -122,18 +122,18 @@ const assertionSuccess = ""
// documentation on specific assertion methods. A failing assertion will
// cause t.Fail() to be invoked--you should never call this method (or other
// failure-inducing methods) in your test code. Leave that to GoConvey.
func So(actual interface{}, assert Assertion, expected ...interface{}) {
func So(actual any, assert Assertion, expected ...any) {
mustGetCurrentContext().So(actual, assert, expected...)
}

// SoMsg is an extension of So that allows you to specify a message to report on error.
func SoMsg(msg string, actual interface{}, assert Assertion, expected ...interface{}) {
func SoMsg(msg string, actual any, assert Assertion, expected ...any) {
mustGetCurrentContext().SoMsg(msg, actual, assert, expected...)
}

// SkipSo is analogous to So except that the assertion that would have been passed
// to So is not executed and the reporter is notified that the assertion was skipped.
func SkipSo(stuff ...interface{}) {
func SkipSo(stuff ...any) {
mustGetCurrentContext().SkipSo()
}

Expand Down Expand Up @@ -222,19 +222,19 @@ func SetDefaultStackMode(mode StackMode) {

// Print is analogous to fmt.Print (and it even calls fmt.Print). It ensures that
// output is aligned with the corresponding scopes in the web UI.
func Print(items ...interface{}) (written int, err error) {
func Print(items ...any) (written int, err error) {
return mustGetCurrentContext().Print(items...)
}

// Print is analogous to fmt.Println (and it even calls fmt.Println). It ensures that
// output is aligned with the corresponding scopes in the web UI.
func Println(items ...interface{}) (written int, err error) {
func Println(items ...any) (written int, err error) {
return mustGetCurrentContext().Println(items...)
}

// Print is analogous to fmt.Printf (and it even calls fmt.Printf). It ensures that
// output is aligned with the corresponding scopes in the web UI.
func Printf(format string, items ...interface{}) (written int, err error) {
func Printf(format string, items ...any) (written int, err error) {
return mustGetCurrentContext().Printf(format, items...)
}

Expand Down
6 changes: 3 additions & 3 deletions convey/reporting/printer.go
Expand Up @@ -11,12 +11,12 @@ type Printer struct {
prefix string
}

func (self *Printer) Println(message string, values ...interface{}) {
func (self *Printer) Println(message string, values ...any) {
formatted := self.format(message, values...) + newline
self.out.Write([]byte(formatted))
}

func (self *Printer) Print(message string, values ...interface{}) {
func (self *Printer) Print(message string, values ...any) {
formatted := self.format(message, values...)
self.out.Write([]byte(formatted))
}
Expand All @@ -25,7 +25,7 @@ func (self *Printer) Insert(text string) {
self.out.Write([]byte(text))
}

func (self *Printer) format(message string, values ...interface{}) string {
func (self *Printer) format(message string, values ...any) string {
var formatted string
if len(values) == 0 {
formatted = self.prefix + message
Expand Down
4 changes: 2 additions & 2 deletions convey/reporting/reports.go
Expand Up @@ -92,7 +92,7 @@ type AssertionResult struct {
Expected string
Actual string
Failure string
Error interface{}
Error any
StackTrace string
Skipped bool
}
Expand All @@ -117,7 +117,7 @@ func parseFailure(failure string, report *AssertionResult) {
report.Failure = failure
}
}
func NewErrorReport(err interface{}) *AssertionResult {
func NewErrorReport(err any) *AssertionResult {
report := new(AssertionResult)
report.File, report.Line = caller()
report.StackTrace = fullStackTrace()
Expand Down
4 changes: 2 additions & 2 deletions convey/reporting_hooks_test.go
Expand Up @@ -248,7 +248,7 @@ func TestEmbeddedContextHelperReported(t *testing.T) {
expectEqual(t, "Begin|A|Embedded|Success|Exit|Exit|End", myReporter.wholeStory())
}

func expectEqual(t *testing.T, expected interface{}, actual interface{}) {
func expectEqual(t *testing.T, expected any, actual any) {
if expected != actual {
_, file, line, _ := runtime.Caller(1)
t.Errorf("Expected '%v' to be '%v' but it wasn't. See '%s' at line %d.",
Expand Down Expand Up @@ -312,6 +312,6 @@ func (self *fakeReporter) wholeStory() string {
type fakeGoTest struct{}

func (self *fakeGoTest) Fail() {}
func (self *fakeGoTest) Fatalf(format string, args ...interface{}) {}
func (self *fakeGoTest) Fatalf(format string, args ...any) {}

var test t = new(fakeGoTest)
2 changes: 1 addition & 1 deletion convey/story_conventions_test.go
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
)

func expectPanic(t *testing.T, f string) interface{} {
func expectPanic(t *testing.T, f string) any {
r := recover()
if r != nil {
if cp, ok := r.(*conveyErr); ok {
Expand Down
13 changes: 9 additions & 4 deletions go.mod
@@ -1,10 +1,15 @@
module github.com/smartystreets/goconvey

go 1.16
go 1.18

require (
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 // indirect
github.com/jtolds/gls v4.20.0+incompatible
github.com/smartystreets/assertions v1.2.0
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384
github.com/smartystreets/assertions v1.13.1
golang.org/x/tools v0.7.0
)

require (
github.com/gopherjs/gopherjs v1.17.2 // indirect
golang.org/x/mod v0.9.0 // indirect
golang.org/x/sys v0.6.0 // indirect
)
21 changes: 11 additions & 10 deletions go.sum
@@ -1,12 +1,13 @@
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gopherjs/gopherjs v1.17.2 h1:fQnZVsXk8uxXIStYb0N4bGk7jeyTalG/wsZjQ25dO0g=
github.com/gopherjs/gopherjs v1.17.2/go.mod h1:pRRIvn/QzFLrKfvEz3qUuEhtE/zLCWfreZ6J5gM2i+k=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs=
github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384 h1:TFlARGu6Czu1z7q93HTxcP1P+/ZFC/IKythI5RzrnRg=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
github.com/smartystreets/assertions v1.13.1 h1:Ef7KhSmjZcK6AVf9YbJdvPYG9avaF0ZxudX+ThRdWfU=
github.com/smartystreets/assertions v1.13.1/go.mod h1:cXr/IwVfSo/RbCSPhoAPv73p3hlSdrBH/b3SdnW/LMY=
golang.org/x/mod v0.9.0 h1:KENHtAZL2y3NLMYZeHY9DW8HW8V+kQyJsY/V9JlKvCs=
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sys v0.6.0 h1:MVltZSvRTcU2ljQOhs94SXPftV6DCNnZViHeQps87pQ=
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/tools v0.7.0 h1:W4OVu8VVOaIO0yzWMNdepAulS7YfoS3Zabrm8DOXXU4=
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
2 changes: 1 addition & 1 deletion web/server/parser/package_parser_test.go
Expand Up @@ -150,7 +150,7 @@ func TestParsePackage_Golang17Subtests_ReturnsPackageResult(t *testing.T) {
assertEqual(t, expectedGolang17Subtests, *actual)
}

func assertEqual(t *testing.T, expected, actual interface{}) {
func assertEqual(t *testing.T, expected, actual any) {
a, _ := json.Marshal(expected)
b, _ := json.Marshal(actual)
if string(a) != string(b) {
Expand Down

0 comments on commit 4aefd2b

Please sign in to comment.