From b818c6b0b19a89443eb192ff2569868167760739 Mon Sep 17 00:00:00 2001 From: ehsandavari Date: Fri, 19 May 2023 16:32:26 +0330 Subject: [PATCH 1/2] change interface{} to any --- CHANGELOG.md | 2 +- core_dsl.go | 56 +++++++++---------- deprecated_dsl.go | 8 +-- docs/MIGRATING_TO_V2.md | 12 ++-- docs/index.md | 30 +++++----- formatter/formatter.go | 12 ++-- ginkgo/command/abort.go | 6 +- ginkgo_t_dsl.go | 22 ++++---- go.mod | 2 +- .../_fixtures/flags_fixture/flags_test.go | 2 +- .../ordered_fixture_suite_test.go | 4 +- .../serial_fixture_suite_test.go | 4 +- integration/report_entries_test.go | 8 +-- internal/failer.go | 2 +- internal/internal_integration/abort_test.go | 4 +- internal/internal_integration/cleanup_test.go | 2 +- .../internal_integration_suite_test.go | 8 +-- internal/internal_integration/ordered_test.go | 2 +- .../internal_integration/parallel_test.go | 4 +- .../report_entries_test.go | 4 +- .../internal_integration/report_suite_test.go | 6 +- internal/internal_integration/serial_test.go | 2 +- .../synchronized_suite_nodes_test.go | 10 ++-- internal/internal_integration/table_test.go | 8 +-- internal/internal_suite_test.go | 6 +- .../interrupt_handler/interrupt_handler.go | 22 ++++---- internal/node.go | 34 +++++------ internal/node_test.go | 24 ++++---- internal/output_interceptor.go | 14 ++--- internal/output_interceptor_unix.go | 2 +- internal/parallel_support/client_server.go | 2 +- .../parallel_support/client_server_test.go | 16 +++--- internal/parallel_support/http_client.go | 4 +- internal/parallel_support/http_server.go | 4 +- internal/parallel_support/rpc_client.go | 2 +- internal/parallel_support/rpc_server.go | 10 ++-- internal/parallel_support/server_handler.go | 4 +- internal/report_entry.go | 2 +- internal/report_entry_test.go | 6 +- .../test_helpers/fake_interrupt_handler.go | 6 +- internal/test_helpers/fake_reporter.go | 22 ++++---- internal/test_helpers/run_tracker.go | 20 +++---- internal/test_helpers/set_up_server.go | 6 +- internal/testingtproxy/testing_t_proxy.go | 22 ++++---- internal/writer.go | 6 +- reporters/default_reporter.go | 4 +- reporters/default_reporter_test.go | 18 +++--- reporting_dsl.go | 18 +++--- table_dsl.go | 40 ++++++------- types/config.go | 16 +++--- types/deprecated_types.go | 2 +- types/errors.go | 8 +-- types/file_filters_test.go | 4 +- types/flags.go | 12 ++-- types/flags_test.go | 10 ++-- types/label_filter_test.go | 2 +- types/report_entry.go | 8 +-- 57 files changed, 298 insertions(+), 298 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1811884b..8bdd901ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -340,7 +340,7 @@ Ginkgo also uses this progress reporting infrastructure under the hood when hand ### Features - `BeforeSuite`, `AfterSuite`, `SynchronizedBeforeSuite`, `SynchronizedAfterSuite`, and `ReportAfterSuite` now support (the relevant subset of) decorators. These can be passed in _after_ the callback functions that are usually passed into these nodes. - As a result the **signature of these methods has changed** and now includes a trailing `args ...interface{}`. For most users simply using the DSL, this change is transparent. However if you were assigning one of these functions to a custom variable (or passing it around) then your code may need to change to reflect the new signature. + As a result the **signature of these methods has changed** and now includes a trailing `args ...any`. For most users simply using the DSL, this change is transparent. However if you were assigning one of these functions to a custom variable (or passing it around) then your code may need to change to reflect the new signature. ### Maintenance - Modernize the invocation of Ginkgo in github actions [0ffde58] diff --git a/core_dsl.go b/core_dsl.go index a244bdc18..232ed6089 100644 --- a/core_dsl.go +++ b/core_dsl.go @@ -83,9 +83,9 @@ func exitIfErrors(errors []error) { type GinkgoWriterInterface interface { io.Writer - Print(a ...interface{}) - Printf(format string, a ...interface{}) - Println(a ...interface{}) + Print(a ...any) + Printf(format string, a ...any) + Println(a ...any) TeeTo(writer io.Writer) ClearTeeWriters() @@ -243,7 +243,7 @@ for more on how specs are parallelized in Ginkgo. You can also pass suite-level Label() decorators to RunSpecs. The passed-in labels will apply to all specs in the suite. */ -func RunSpecs(t GinkgoTestingT, description string, args ...interface{}) bool { +func RunSpecs(t GinkgoTestingT, description string, args ...any) bool { if suiteDidRun { exitIfErr(types.GinkgoErrors.RerunningSuite()) } @@ -438,14 +438,14 @@ to Describe the behavior of an object or function and, within that Describe, out You can learn more at https://onsi.github.io/ginkgo/#organizing-specs-with-container-nodes In addition, container nodes can be decorated with a variety of decorators. You can learn more here: https://onsi.github.io/ginkgo/#decorator-reference */ -func Describe(text string, args ...interface{}) bool { +func Describe(text string, args ...any) bool { return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, text, args...)) } /* FDescribe focuses specs within the Describe block. */ -func FDescribe(text string, args ...interface{}) bool { +func FDescribe(text string, args ...any) bool { args = append(args, internal.Focus) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, text, args...)) } @@ -453,7 +453,7 @@ func FDescribe(text string, args ...interface{}) bool { /* PDescribe marks specs within the Describe block as pending. */ -func PDescribe(text string, args ...interface{}) bool { +func PDescribe(text string, args ...any) bool { args = append(args, internal.Pending) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, text, args...)) } @@ -469,18 +469,18 @@ var XDescribe = PDescribe var Context, FContext, PContext, XContext = Describe, FDescribe, PDescribe, XDescribe /* When is an alias for Describe - it generates the exact same kind of Container node */ -func When(text string, args ...interface{}) bool { +func When(text string, args ...any) bool { return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, "when "+text, args...)) } /* When is an alias for Describe - it generates the exact same kind of Container node */ -func FWhen(text string, args ...interface{}) bool { +func FWhen(text string, args ...any) bool { args = append(args, internal.Focus) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, "when "+text, args...)) } /* When is an alias for Describe - it generates the exact same kind of Container node */ -func PWhen(text string, args ...interface{}) bool { +func PWhen(text string, args ...any) bool { args = append(args, internal.Pending) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, "when "+text, args...)) } @@ -497,14 +497,14 @@ You can pass It nodes bare functions (func() {}) or functions that receive a Spe You can learn more at https://onsi.github.io/ginkgo/#spec-subjects-it In addition, subject nodes can be decorated with a variety of decorators. You can learn more here: https://onsi.github.io/ginkgo/#decorator-reference */ -func It(text string, args ...interface{}) bool { +func It(text string, args ...any) bool { return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeIt, text, args...)) } /* FIt allows you to focus an individual It. */ -func FIt(text string, args ...interface{}) bool { +func FIt(text string, args ...any) bool { args = append(args, internal.Focus) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeIt, text, args...)) } @@ -512,7 +512,7 @@ func FIt(text string, args ...interface{}) bool { /* PIt allows you to mark an individual It as pending. */ -func PIt(text string, args ...interface{}) bool { +func PIt(text string, args ...any) bool { args = append(args, internal.Pending) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeIt, text, args...)) } @@ -558,8 +558,8 @@ BeforeSuite can take a func() body, or an interruptible func(SpecContext)/func(c You cannot nest any other Ginkgo nodes within a BeforeSuite node's closure. You can learn more here: https://onsi.github.io/ginkgo/#suite-setup-and-cleanup-beforesuite-and-aftersuite */ -func BeforeSuite(body interface{}, args ...interface{}) bool { - combinedArgs := []interface{}{body} +func BeforeSuite(body any, args ...any) bool { + combinedArgs := []any{body} combinedArgs = append(combinedArgs, args...) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeBeforeSuite, "", combinedArgs...)) } @@ -577,8 +577,8 @@ AfterSuite can take a func() body, or an interruptible func(SpecContext)/func(co You cannot nest any other Ginkgo nodes within an AfterSuite node's closure. You can learn more here: https://onsi.github.io/ginkgo/#suite-setup-and-cleanup-beforesuite-and-aftersuite */ -func AfterSuite(body interface{}, args ...interface{}) bool { - combinedArgs := []interface{}{body} +func AfterSuite(body any, args ...any) bool { + combinedArgs := []any{body} combinedArgs = append(combinedArgs, args...) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeAfterSuite, "", combinedArgs...)) } @@ -614,8 +614,8 @@ If either function receives a context.Context/SpecContext it is considered inter You cannot nest any other Ginkgo nodes within an SynchronizedBeforeSuite node's closure. You can learn more, and see some examples, here: https://onsi.github.io/ginkgo/#parallel-suite-setup-and-cleanup-synchronizedbeforesuite-and-synchronizedaftersuite */ -func SynchronizedBeforeSuite(process1Body interface{}, allProcessBody interface{}, args ...interface{}) bool { - combinedArgs := []interface{}{process1Body, allProcessBody} +func SynchronizedBeforeSuite(process1Body any, allProcessBody any, args ...any) bool { + combinedArgs := []any{process1Body, allProcessBody} combinedArgs = append(combinedArgs, args...) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeSynchronizedBeforeSuite, "", combinedArgs...)) @@ -634,8 +634,8 @@ Note that you can also use DeferCleanup() in SynchronizedBeforeSuite to accompli You cannot nest any other Ginkgo nodes within an SynchronizedAfterSuite node's closure. You can learn more, and see some examples, here: https://onsi.github.io/ginkgo/#parallel-suite-setup-and-cleanup-synchronizedbeforesuite-and-synchronizedaftersuite */ -func SynchronizedAfterSuite(allProcessBody interface{}, process1Body interface{}, args ...interface{}) bool { - combinedArgs := []interface{}{allProcessBody, process1Body} +func SynchronizedAfterSuite(allProcessBody any, process1Body any, args ...any) bool { + combinedArgs := []any{allProcessBody, process1Body} combinedArgs = append(combinedArgs, args...) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeSynchronizedAfterSuite, "", combinedArgs...)) @@ -650,7 +650,7 @@ BeforeEach can take a func() body, or an interruptible func(SpecContext)/func(co You cannot nest any other Ginkgo nodes within a BeforeEach node's closure. You can learn more here: https://onsi.github.io/ginkgo/#extracting-common-setup-beforeeach */ -func BeforeEach(args ...interface{}) bool { +func BeforeEach(args ...any) bool { return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeBeforeEach, "", args...)) } @@ -663,7 +663,7 @@ JustBeforeEach can take a func() body, or an interruptible func(SpecContext)/fun You cannot nest any other Ginkgo nodes within a JustBeforeEach node's closure. You can learn more and see some examples here: https://onsi.github.io/ginkgo/#separating-creation-and-configuration-justbeforeeach */ -func JustBeforeEach(args ...interface{}) bool { +func JustBeforeEach(args ...any) bool { return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeJustBeforeEach, "", args...)) } @@ -678,7 +678,7 @@ AfterEach can take a func() body, or an interruptible func(SpecContext)/func(con You cannot nest any other Ginkgo nodes within an AfterEach node's closure. You can learn more here: https://onsi.github.io/ginkgo/#spec-cleanup-aftereach-and-defercleanup */ -func AfterEach(args ...interface{}) bool { +func AfterEach(args ...any) bool { return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeAfterEach, "", args...)) } @@ -690,7 +690,7 @@ JustAfterEach can take a func() body, or an interruptible func(SpecContext)/func You cannot nest any other Ginkgo nodes within a JustAfterEach node's closure. You can learn more and see some examples here: https://onsi.github.io/ginkgo/#separating-diagnostics-collection-and-teardown-justaftereach */ -func JustAfterEach(args ...interface{}) bool { +func JustAfterEach(args ...any) bool { return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeJustAfterEach, "", args...)) } @@ -705,7 +705,7 @@ You cannot nest any other Ginkgo nodes within a BeforeAll node's closure. You can learn more about Ordered Containers at: https://onsi.github.io/ginkgo/#ordered-containers And you can learn more about BeforeAll at: https://onsi.github.io/ginkgo/#setup-in-ordered-containers-beforeall-and-afterall */ -func BeforeAll(args ...interface{}) bool { +func BeforeAll(args ...any) bool { return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeBeforeAll, "", args...)) } @@ -722,7 +722,7 @@ You cannot nest any other Ginkgo nodes within an AfterAll node's closure. You can learn more about Ordered Containers at: https://onsi.github.io/ginkgo/#ordered-containers And you can learn more about AfterAll at: https://onsi.github.io/ginkgo/#setup-in-ordered-containers-beforeall-and-afterall */ -func AfterAll(args ...interface{}) bool { +func AfterAll(args ...any) bool { return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeAfterAll, "", args...)) } @@ -765,7 +765,7 @@ When DeferCleanup is called in BeforeSuite, SynchronizedBeforeSuite, AfterSuite, Note that DeferCleanup does not represent a node but rather dynamically generates the appropriate type of cleanup node based on the context in which it is called. As such you must call DeferCleanup within a Setup or Subject node, and not within a Container node. You can learn more about DeferCleanup here: https://onsi.github.io/ginkgo/#cleaning-up-our-cleanup-code-defercleanup */ -func DeferCleanup(args ...interface{}) { +func DeferCleanup(args ...any) { fail := func(message string, cl types.CodeLocation) { global.Failer.Fail(message, cl) } diff --git a/deprecated_dsl.go b/deprecated_dsl.go index f912bbec6..fd45b8bea 100644 --- a/deprecated_dsl.go +++ b/deprecated_dsl.go @@ -118,9 +118,9 @@ Use Gomega's gmeasure package instead. You can learn more here: https://onsi.github.io/ginkgo/#benchmarking-code */ type Benchmarker interface { - Time(name string, body func(), info ...interface{}) (elapsedTime time.Duration) - RecordValue(name string, value float64, info ...interface{}) - RecordValueWithPrecision(name string, value float64, units string, precision int, info ...interface{}) + Time(name string, body func(), info ...any) (elapsedTime time.Duration) + RecordValue(name string, value float64, info ...any) + RecordValueWithPrecision(name string, value float64, units string, precision int, info ...any) } /* @@ -129,7 +129,7 @@ Deprecated: Measure() has been removed from Ginkgo 2.0 Use Gomega's gmeasure package instead. You can learn more here: https://onsi.github.io/ginkgo/#benchmarking-code */ -func Measure(_ ...interface{}) bool { +func Measure(_ ...any) bool { deprecationTracker.TrackDeprecation(types.Deprecations.Measure(), types.NewCodeLocation(1)) return true } diff --git a/docs/MIGRATING_TO_V2.md b/docs/MIGRATING_TO_V2.md index 97f620485..dfa96e35d 100644 --- a/docs/MIGRATING_TO_V2.md +++ b/docs/MIGRATING_TO_V2.md @@ -59,9 +59,9 @@ Specs can now be decorated with a series of new spec decorators. These decorato To support decorators, the signature for Ginkgo's container, setup, and It nodes have been changed to: ```go -func Describe(text string, args ...interface{}) -func It(text string, args ...interface{}) -func BeforeEach(args ...interface{}) +func Describe(text string, args ...any) +func It(text string, args ...any) +func BeforeEach(args ...any) ``` Note that this change is backwards compatible with v1.X. @@ -234,7 +234,7 @@ Ginkgo's CLI flags have been rewritten to provide clearer, better-organized docu The `GinkgoWriter` is used to write output that is only made visible if a test fails, or if the user runs in verbose mode with `ginkgo -v`. In Ginkgo 2.0 `GinkgoWriter` now has: - - Three new convenience methods `GinkgoWriter.Print(a ...interface{})`, `GinkgoWriter.Println(a ...interface{})`, `GinkgoWriter.Printf(format string, a ...interface{})` These are equivalent to calling the associated `fmt.Fprint*` functions and passing in `GinkgoWriter`. + - Three new convenience methods `GinkgoWriter.Print(a ...any)`, `GinkgoWriter.Println(a ...any)`, `GinkgoWriter.Printf(format string, a ...any)` These are equivalent to calling the associated `fmt.Fprint*` functions and passing in `GinkgoWriter`. - The ability to tee to additional writers. `GinkgoWriter.TeeTo(writer)` will send any future data written to `GinkgoWriter` to the passed in `writer`. You can attach multiple `io.Writer`s for `GinkgoWriter` to tee to. You can remove all attached writers with `GinkgoWriter.ClearTeeWriters()`. Note that _all_ data written to `GinkgoWriter` is immediately forwarded to attached tee writers regardless of where a test passes or fails. @@ -293,14 +293,14 @@ Ginkgo V2 supports attaching arbitrary data to individual spec reports. These a You attach data to a spec report via ```go -AddReportEntry(name string, args ...interface{}) +AddReportEntry(name string, args ...any) ``` `AddReportEntry` can be called from any runnable node (e.g. `It`, `BeforeEach`, `BeforeSuite`) - but not from the body of a container node (e.g. `Describe`, `Context`). `AddReportEntry` generates `ReportEntry` and attaches it to the current running spec. `ReportEntry` includes the passed in `name` as well as the time and source location at which `AddReportEntry` was called. Users can also attach a single object of arbitrary type to the `ReportEntry` by passing it into `AddReportEntry` - this object is wrapped and stored under `ReportEntry.Value` and is always included in the suite's JSON report. -You can access the report entries attached to a spec by getting the `CurrentSpecReport()` or registering a `ReportAfterEach()` - the returned report will include the attached `ReportEntries`. You can fetch the value associated with the `ReportEntry` by calling `entry.GetRawValue()`. When called in-process this returns the object that was passed to `AddReportEntry`. When called after hydrating a report from JSON `entry.GetRawValue()` will include a parsed JSON `interface{}` - if you want to hydrate the JSON yourself into an object of known type you can `json.Unmarshal([]byte(entry.Value.AsJSON), &object)`. +You can access the report entries attached to a spec by getting the `CurrentSpecReport()` or registering a `ReportAfterEach()` - the returned report will include the attached `ReportEntries`. You can fetch the value associated with the `ReportEntry` by calling `entry.GetRawValue()`. When called in-process this returns the object that was passed to `AddReportEntry`. When called after hydrating a report from JSON `entry.GetRawValue()` will include a parsed JSON `any` - if you want to hydrate the JSON yourself into an object of known type you can `json.Unmarshal([]byte(entry.Value.AsJSON), &object)`. #### Supported Args `AddReportEntry` supports the `Offset` and `CodeLocation` decorators. These will control the source code location associated with the generated `ReportEntry`. You can also pass in a `time.Time` to override the `ReportEntry`'s timestamp. It also supports passing in a `ReportEntryVisibility` enum to control the report's visibility (see below). diff --git a/docs/index.md b/docs/index.md index e9fb28c25..64174b05c 100644 --- a/docs/index.md +++ b/docs/index.md @@ -1204,7 +1204,7 @@ Ginkgo orchestrates this behavior by rescuing the panic thrown by `Fail` and unw ```go It("panics in a goroutine", func() { - var c chan interface{} + var c chan any go func() { defer GinkgoRecover() Fail("boom") @@ -1287,9 +1287,9 @@ Ginkgo provides a globally available `io.Writer` called `GinkgoWriter` that solv `GinkgoWriter` includes three convenience methods: -- `GinkgoWriter.Print(a ...interface{})` is equivalent to `fmt.Fprint(GinkgoWriter, a...)` -- `GinkgoWriter.Println(a ...interface{})` is equivalent to `fmt.Fprintln(GinkgoWriter, a...)` -- `GinkgoWriter.Printf(format string, a ...interface{})` is equivalent to `fmt.Fprintf(GinkgoWriter, format, a...)` +- `GinkgoWriter.Print(a ...any)` is equivalent to `fmt.Fprint(GinkgoWriter, a...)` +- `GinkgoWriter.Println(a ...any)` is equivalent to `fmt.Fprintln(GinkgoWriter, a...)` +- `GinkgoWriter.Printf(format string, a ...any)` is equivalent to `fmt.Fprintf(GinkgoWriter, format, a...)` You can also attach additional `io.Writer`s for `GinkgoWriter` to tee to via `GinkgoWriter.TeeTo(writer)`. Any data written to `GinkgoWriter` will immediately be sent to attached tee writers. All attached Tee writers can be cleared with `GinkgoWriter.ClearTeeWriters()`. @@ -2067,8 +2067,8 @@ It("description", ) In actuality, the signatures for these functions is actually: ```go -Describe("description", args ...interface{}) -It("description", args ...interface{}) +Describe("description", args ...any) +It("description", args ...any) ``` and Ginkgo provides a number of additional types that can be passed in to container and subject nodes. We call these types Spec Decorators as they decorate the spec with additional metadata. This metadata can modify the behavior of the spec at run time. A comprehensive [reference of all decorators](#decorator-reference) is maintained in these docs. @@ -3449,12 +3449,12 @@ Ginkgo supports attaching arbitrary data to individual spec reports. These are You attach data to a spec report via ```go -AddReportEntry(name string, args ...interface{}) +AddReportEntry(name string, args ...any) ``` `AddReportEntry` can be called from any setup or subject node closure. When called, `AddReportEntry` generates `ReportEntry` and attaches it to the current running spec. `ReportEntry` includes the passed in `name` as well as the time and source location at which `AddReportEntry` was called. Users can also attach a single object of arbitrary type to the `ReportEntry` by passing it into `AddReportEntry` - this object is wrapped and stored under `ReportEntry.Value` and is always included in the suite's JSON report. -You can access the report entries attached to a spec by getting the `CurrentSpecReport()` or registering a `ReportAfterEach()` - the returned report will include the attached `ReportEntries`. You can fetch the value associated with the `ReportEntry` by calling `entry.GetRawValue()`. When called in-process this returns the object that was passed to `AddReportEntry`. When called after hydrating a report from JSON `entry.GetRawValue()` will include a parsed JSON `interface{}` - if you want to hydrate the JSON yourself into an object of known type you can `json.Unmarshal([]byte(entry.Value.AsJSON), &object)`. +You can access the report entries attached to a spec by getting the `CurrentSpecReport()` or registering a `ReportAfterEach()` - the returned report will include the attached `ReportEntries`. You can fetch the value associated with the `ReportEntry` by calling `entry.GetRawValue()`. When called in-process this returns the object that was passed to `AddReportEntry`. When called after hydrating a report from JSON `entry.GetRawValue()` will include a parsed JSON `any` - if you want to hydrate the JSON yourself into an object of known type you can `json.Unmarshal([]byte(entry.Value.AsJSON), &object)`. #### Supported Args `AddReportEntry` supports the `Offset` and `CodeLocation` decorators. These will control the source code location associated with the generated `ReportEntry`. You can also pass in a `time.Time` argument to override the timestamp associated with the `ReportEntry` - this can be helpful if you want to ensure a consistent timestamp between your code and the `ReportEntry`. @@ -4224,7 +4224,7 @@ Describe("Change book font-size", func() { }) It("can repaginate books without losing any content", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() @@ -4859,7 +4859,7 @@ type Title string type Author string type Pages int -func BeAValidBook(params ...interface{}) types.GomegaMatcher { +func BeAValidBook(params ...any) types.GomegaMatcher { matchers := []types.GomegaMatcher{ WithTransform(func(book *books.Book) bool { return book.IsValid() @@ -4900,12 +4900,12 @@ The failure messages generated by composed matchers are generally good enough to We've seen a number of Decorators detailed throughout this documentation. This reference collects them all in one place. #### Node Decorators Overview -Ginkgo's container nodes, subject nodes, and setup nodes all accept decorators. Decorators are specially typed arguments passed into the node constructors. They can appear anywhere in the `args ...interface{}` list in the constructor signatures: +Ginkgo's container nodes, subject nodes, and setup nodes all accept decorators. Decorators are specially typed arguments passed into the node constructors. They can appear anywhere in the `args ...any` list in the constructor signatures: ```go -func Describe(text string, args ...interface{}) -func It(text string, args ...interface{}) -func BeforeEach(args ...interface{}) +func Describe(text string, args ...any) +func It(text string, args ...any) +func BeforeEach(args ...any) ``` Ginkgo will vet the passed in decorators and exit with a clear error message if it detects any invalid configurations. @@ -4913,7 +4913,7 @@ Ginkgo will vet the passed in decorators and exit with a clear error message if Moreover, Ginkgo also supports passing in arbitrarily nested slices of decorators. Ginkgo will unroll these slices and process the flattened list. This makes it easier to pass around groups of decorators. For example, this is valid: ```go -markFlaky := []interface{}{Label("flaky"), FlakeAttempts(3)} +markFlaky := []any{Label("flaky"), FlakeAttempts(3)} var _ = Describe("a bunch of flaky controller tests", markFlaky, Label("controller"), func() { ... diff --git a/formatter/formatter.go b/formatter/formatter.go index 743555dde..8ea9d3dae 100644 --- a/formatter/formatter.go +++ b/formatter/formatter.go @@ -24,15 +24,15 @@ const ( var SingletonFormatter = New(ColorModeTerminal) -func F(format string, args ...interface{}) string { +func F(format string, args ...any) string { return SingletonFormatter.F(format, args...) } -func Fi(indentation uint, format string, args ...interface{}) string { +func Fi(indentation uint, format string, args ...any) string { return SingletonFormatter.Fi(indentation, format, args...) } -func Fiw(indentation uint, maxWidth uint, format string, args ...interface{}) string { +func Fiw(indentation uint, maxWidth uint, format string, args ...any) string { return SingletonFormatter.Fiw(indentation, maxWidth, format, args...) } @@ -111,15 +111,15 @@ func New(colorMode ColorMode) Formatter { return f } -func (f Formatter) F(format string, args ...interface{}) string { +func (f Formatter) F(format string, args ...any) string { return f.Fi(0, format, args...) } -func (f Formatter) Fi(indentation uint, format string, args ...interface{}) string { +func (f Formatter) Fi(indentation uint, format string, args ...any) string { return f.Fiw(indentation, 0, format, args...) } -func (f Formatter) Fiw(indentation uint, maxWidth uint, format string, args ...interface{}) string { +func (f Formatter) Fiw(indentation uint, maxWidth uint, format string, args ...any) string { out := f.style(format) if len(args) > 0 { out = fmt.Sprintf(out, args...) diff --git a/ginkgo/command/abort.go b/ginkgo/command/abort.go index 2efd28608..f0e7331f7 100644 --- a/ginkgo/command/abort.go +++ b/ginkgo/command/abort.go @@ -12,7 +12,7 @@ func Abort(details AbortDetails) { panic(details) } -func AbortGracefullyWith(format string, args ...interface{}) { +func AbortGracefullyWith(format string, args ...any) { Abort(AbortDetails{ ExitCode: 0, Error: fmt.Errorf(format, args...), @@ -20,7 +20,7 @@ func AbortGracefullyWith(format string, args ...interface{}) { }) } -func AbortWith(format string, args ...interface{}) { +func AbortWith(format string, args ...any) { Abort(AbortDetails{ ExitCode: 1, Error: fmt.Errorf(format, args...), @@ -28,7 +28,7 @@ func AbortWith(format string, args ...interface{}) { }) } -func AbortWithUsage(format string, args ...interface{}) { +func AbortWithUsage(format string, args ...any) { Abort(AbortDetails{ ExitCode: 1, Error: fmt.Errorf(format, args...), diff --git a/ginkgo_t_dsl.go b/ginkgo_t_dsl.go index 28447ffdd..cd7cc14d4 100644 --- a/ginkgo_t_dsl.go +++ b/ginkgo_t_dsl.go @@ -41,21 +41,21 @@ The portion of the interface returned by GinkgoT() that maps onto methods in the type GinkgoTInterface interface { Cleanup(func()) Setenv(kev, value string) - Error(args ...interface{}) - Errorf(format string, args ...interface{}) + Error(args ...any) + Errorf(format string, args ...any) Fail() FailNow() Failed() bool - Fatal(args ...interface{}) - Fatalf(format string, args ...interface{}) + Fatal(args ...any) + Fatalf(format string, args ...any) Helper() - Log(args ...interface{}) - Logf(format string, args ...interface{}) + Log(args ...any) + Logf(format string, args ...any) Name() string Parallel() - Skip(args ...interface{}) + Skip(args ...any) SkipNow() - Skipf(format string, args ...interface{}) + Skipf(format string, args ...any) Skipped() bool TempDir() string } @@ -71,9 +71,9 @@ type FullGinkgoTInterface interface { AddReportEntryVisibilityNever(name string, args ...any) //Prints to the GinkgoWriter - Print(a ...interface{}) - Printf(format string, a ...interface{}) - Println(a ...interface{}) + Print(a ...any) + Printf(format string, a ...any) + Println(a ...any) //Provides access to Ginkgo's color formatting, correctly configured to match the color settings specified in the invocation of ginkgo F(format string, args ...any) string diff --git a/go.mod b/go.mod index f6ce764f4..d89532418 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/onsi/ginkgo/v2 -go 1.18 +go 1.20 require ( github.com/go-logr/logr v1.2.4 diff --git a/integration/_fixtures/flags_fixture/flags_test.go b/integration/_fixtures/flags_fixture/flags_test.go index 3c2770453..2e79bf0b3 100644 --- a/integration/_fixtures/flags_fixture/flags_test.go +++ b/integration/_fixtures/flags_fixture/flags_test.go @@ -41,7 +41,7 @@ var _ = Describe("Testing various flags", func() { It("should detect races", func() { var a string - c := make(chan interface{}, 0) + c := make(chan any, 0) go func() { a = "now you don't" close(c) diff --git a/integration/_fixtures/ordered_fixture/ordered_fixture_suite_test.go b/integration/_fixtures/ordered_fixture/ordered_fixture_suite_test.go index f50bb53e7..71c30c545 100644 --- a/integration/_fixtures/ordered_fixture/ordered_fixture_suite_test.go +++ b/integration/_fixtures/ordered_fixture/ordered_fixture_suite_test.go @@ -14,12 +14,12 @@ func init() { noOrdered = flag.CommandLine.Bool("no-ordered", false, "set to turn off ordered decoration") } -var OrderedDecoration = []interface{}{Ordered} +var OrderedDecoration = []any{Ordered} func TestOrderedFixture(t *testing.T) { RegisterFailHandler(Fail) if *noOrdered { - OrderedDecoration = []interface{}{} + OrderedDecoration = []any{} } RunSpecs(t, "OrderedFixture Suite") diff --git a/integration/_fixtures/serial_fixture/serial_fixture_suite_test.go b/integration/_fixtures/serial_fixture/serial_fixture_suite_test.go index 1ae57298e..3b46ae2d6 100644 --- a/integration/_fixtures/serial_fixture/serial_fixture_suite_test.go +++ b/integration/_fixtures/serial_fixture/serial_fixture_suite_test.go @@ -20,12 +20,12 @@ func init() { noSerial = flag.CommandLine.Bool("no-serial", false, "set to turn off serial decoration") } -var SerialDecoration = []interface{}{Serial} +var SerialDecoration = []any{Serial} func TestSerialFixture(t *testing.T) { RegisterFailHandler(Fail) if *noSerial { - SerialDecoration = []interface{}{} + SerialDecoration = []any{} } RunSpecs(t, "SerialFixture Suite") diff --git a/integration/report_entries_test.go b/integration/report_entries_test.go index 0ec11e75e..d455584f7 100644 --- a/integration/report_entries_test.go +++ b/integration/report_entries_test.go @@ -50,7 +50,7 @@ var _ = Describe("ReportEntries", func() { passes := reports.Find("passes") Ω(passes.ReportEntries).Should(HaveLen(6)) Ω(passes.ReportEntries[0].Name).Should(Equal("passes-first-report")) - Ω(passes.ReportEntries[0].GetRawValue()).Should(Equal(map[string]interface{}{"Label": "pass-bob", "Count": float64(1)})) + Ω(passes.ReportEntries[0].GetRawValue()).Should(Equal(map[string]any{"Label": "pass-bob", "Count": float64(1)})) Ω(passes.ReportEntries[0].StringRepresentation()).Should(Equal("{{red}}pass-bob {{green}}1{{/}}")) Ω(passes.ReportEntries[0].Time).Should(BeTemporally("~", time.Now(), time.Minute)) @@ -63,7 +63,7 @@ var _ = Describe("ReportEntries", func() { Ω(passes.ReportEntries[2].StringRepresentation()).Should(Equal("3")) Ω(passes.ReportEntries[3].Name).Should(Equal("passes-pointer-report")) - Ω(passes.ReportEntries[3].GetRawValue()).Should(Equal(map[string]interface{}{"Label": "passed", "Count": float64(4)})) + Ω(passes.ReportEntries[3].GetRawValue()).Should(Equal(map[string]any{"Label": "passed", "Count": float64(4)})) Ω(passes.ReportEntries[3].StringRepresentation()).Should(Equal("{{red}}passed {{green}}4{{/}}")) Ω(passes.ReportEntries[4].Name).Should(Equal("passes-failure-report")) @@ -76,7 +76,7 @@ var _ = Describe("ReportEntries", func() { fails := reports.Find("fails") Ω(fails.ReportEntries[0].Name).Should(Equal("fails-first-report")) - Ω(fails.ReportEntries[0].GetRawValue()).Should(Equal(map[string]interface{}{"Label": "fail-bob", "Count": float64(1)})) + Ω(fails.ReportEntries[0].GetRawValue()).Should(Equal(map[string]any{"Label": "fail-bob", "Count": float64(1)})) Ω(fails.ReportEntries[0].StringRepresentation()).Should(Equal("{{red}}fail-bob {{green}}1{{/}}")) Ω(fails.ReportEntries[0].Time).Should(BeTemporally("~", time.Now(), time.Minute)) @@ -89,7 +89,7 @@ var _ = Describe("ReportEntries", func() { Ω(fails.ReportEntries[2].StringRepresentation()).Should(Equal("3")) Ω(fails.ReportEntries[3].Name).Should(Equal("fails-pointer-report")) - Ω(fails.ReportEntries[3].GetRawValue()).Should(Equal(map[string]interface{}{"Label": "failed", "Count": float64(4)})) + Ω(fails.ReportEntries[3].GetRawValue()).Should(Equal(map[string]any{"Label": "failed", "Count": float64(4)})) Ω(fails.ReportEntries[3].StringRepresentation()).Should(Equal("{{red}}failed {{green}}4{{/}}")) Ω(fails.ReportEntries[4].Name).Should(Equal("fails-failure-report")) diff --git a/internal/failer.go b/internal/failer.go index e9bd9565f..8c5de9c16 100644 --- a/internal/failer.go +++ b/internal/failer.go @@ -32,7 +32,7 @@ func (f *Failer) GetFailure() types.Failure { return f.failure } -func (f *Failer) Panic(location types.CodeLocation, forwardedPanic interface{}) { +func (f *Failer) Panic(location types.CodeLocation, forwardedPanic any) { f.lock.Lock() defer f.lock.Unlock() diff --git a/internal/internal_integration/abort_test.go b/internal/internal_integration/abort_test.go index 223b212e0..144d87592 100644 --- a/internal/internal_integration/abort_test.go +++ b/internal/internal_integration/abort_test.go @@ -161,10 +161,10 @@ var _ = Describe("handling test aborts", func() { }) Describe("when running in parallel and a test aborts", func() { - var c chan interface{} + var c chan any BeforeEach(func() { SetUpForParallel(2) - c = make(chan interface{}) + c = make(chan any) }) It("notifies the server of the abort", func() { diff --git a/internal/internal_integration/cleanup_test.go b/internal/internal_integration/cleanup_test.go index 6b738f35c..36da6af33 100644 --- a/internal/internal_integration/cleanup_test.go +++ b/internal/internal_integration/cleanup_test.go @@ -234,7 +234,7 @@ var _ = Describe("Cleanup", func() { Context("as process #1", func() { It("runs the cleanup only _after_ the other processes have finished", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() success, _ := RunFixture("DeferCleanup on SBS in parallel on process 1", fixture) diff --git a/internal/internal_integration/internal_integration_suite_test.go b/internal/internal_integration/internal_integration_suite_test.go index 7264e2f3a..bca61a27d 100644 --- a/internal/internal_integration/internal_integration_suite_test.go +++ b/internal/internal_integration/internal_integration_suite_test.go @@ -39,7 +39,7 @@ var outputInterceptor *FakeOutputInterceptor var server parallel_support.Server var client parallel_support.Client -var exitChannels map[int]chan interface{} +var exitChannels map[int]chan any var triggerProgressSignal func() @@ -141,7 +141,7 @@ func RunFixtureInParallel(description string, callback func(proc int)) bool { return success } -func F(options ...interface{}) { +func F(options ...any) { location := cl message := "fail" for _, option := range options { @@ -156,7 +156,7 @@ func F(options ...interface{}) { panic("panic to simulate how ginkgo's Fail works") } -func Abort(options ...interface{}) { +func Abort(options ...any) { location := cl message := "abort" for _, option := range options { @@ -171,7 +171,7 @@ func Abort(options ...interface{}) { panic("panic to simulate how ginkgo's AbortSuite works") } -func FixtureSkip(options ...interface{}) { +func FixtureSkip(options ...any) { location := cl message := "skip" for _, option := range options { diff --git a/internal/internal_integration/ordered_test.go b/internal/internal_integration/ordered_test.go index 4b59d3ade..118078ab1 100644 --- a/internal/internal_integration/ordered_test.go +++ b/internal/internal_integration/ordered_test.go @@ -45,7 +45,7 @@ var FlakeyFailerWithCleanup = func(n int, cleanupLabel string) func() { } var _ = DescribeTable("Ordered Containers", - func(expectedSuccess bool, fixture func(), runs []string, args ...interface{}) { + func(expectedSuccess bool, fixture func(), runs []string, args ...any) { success, _ := RunFixture(CurrentSpecReport().LeafNodeText, fixture) Ω(success).Should(Equal(expectedSuccess)) Ω(rt).Should(HaveTracked(runs...)) diff --git a/internal/internal_integration/parallel_test.go b/internal/internal_integration/parallel_test.go index 880d98a82..4a91f3ad7 100644 --- a/internal/internal_integration/parallel_test.go +++ b/internal/internal_integration/parallel_test.go @@ -14,7 +14,7 @@ var _ = Describe("Running tests in parallel", func() { var conf2 types.SuiteConfig var reporter2 *FakeReporter var rt2 *RunTracker - var serialValidator chan interface{} + var serialValidator chan any var fixture = func(rt *RunTracker, proc int) { SynchronizedBeforeSuite(func() []byte { @@ -84,7 +84,7 @@ var _ = Describe("Running tests in parallel", func() { } BeforeEach(func() { - serialValidator = make(chan interface{}) + serialValidator = make(chan any) //set up configuration for proc 1 and proc 2 //SetUpForParallel starts up a server, sets up a client, and sets up the exitChannels map - they're all cleaned up automatically after the test diff --git a/internal/internal_integration/report_entries_test.go b/internal/internal_integration/report_entries_test.go index d2d7cf4c1..ccea98089 100644 --- a/internal/internal_integration/report_entries_test.go +++ b/internal/internal_integration/report_entries_test.go @@ -49,8 +49,8 @@ var _ = Describe("ReportEntries", func() { BeforeEach(func() { success, _ := RunFixture("Report Entries - but no races", func() { BeforeEach(func() { - stop := make(chan interface{}) - done := make(chan interface{}) + stop := make(chan any) + done := make(chan any) ticker := time.NewTicker(10 * time.Millisecond) i := 0 go func() { diff --git a/internal/internal_integration/report_suite_test.go b/internal/internal_integration/report_suite_test.go index 0c09da03a..9a7e70102 100644 --- a/internal/internal_integration/report_suite_test.go +++ b/internal/internal_integration/report_suite_test.go @@ -292,7 +292,7 @@ var _ = Describe("Sending reports to ReportBeforeSuite and ReportAfterSuite node Describe("waiting for reports from other procs", func() { It("blocks until the other procs have finished", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() success, _ := RunFixture("happy-path", fixture) @@ -353,9 +353,9 @@ var _ = Describe("Sending reports to ReportBeforeSuite and ReportAfterSuite node }) Context("on a non-primary proc", func() { - var done chan interface{} + var done chan any BeforeEach(func() { - done = make(chan interface{}) + done = make(chan any) go func() { conf.ParallelProcess = 2 success, _ := RunFixture("non-primary proc", fixture) diff --git a/internal/internal_integration/serial_test.go b/internal/internal_integration/serial_test.go index e9bd0410d..35d8201f8 100644 --- a/internal/internal_integration/serial_test.go +++ b/internal/internal_integration/serial_test.go @@ -50,7 +50,7 @@ var _ = Describe("Serial", func() { }) It("participates in running parallel tests, then runs the serial tests after all other procs have finished", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() success, _ := RunFixture("happy-path", fixture) diff --git a/internal/internal_integration/synchronized_suite_nodes_test.go b/internal/internal_integration/synchronized_suite_nodes_test.go index 8d12b18b8..13ed2a587 100644 --- a/internal/internal_integration/synchronized_suite_nodes_test.go +++ b/internal/internal_integration/synchronized_suite_nodes_test.go @@ -234,7 +234,7 @@ var _ = Describe("Synchronized Suite Nodes", func() { Describe("waiting for all procs to finish before running the AfterSuite proc 1 function", func() { It("waits for the server to give it the all clear", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() success, _ := RunFixture("happy-path", fixture) @@ -280,7 +280,7 @@ var _ = Describe("Synchronized Suite Nodes", func() { Describe("waiting for the data from proc 1", func() { It("waits for the server to give it the data", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() success, _ := RunFixture("happy-path", fixture) @@ -296,7 +296,7 @@ var _ = Describe("Synchronized Suite Nodes", func() { Describe("when proc 1 fails the SynchronizedBeforeSuite proc1 function", func() { It("fails and only runs the after suite", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() success, _ := RunFixture("happy-path", fixture) @@ -315,7 +315,7 @@ var _ = Describe("Synchronized Suite Nodes", func() { Describe("when the proc1 SynchronizedBeforeSuite function Skips()", func() { It("fails and only runs the after suite", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() success, _ := RunFixture("happy-path", fixture) @@ -334,7 +334,7 @@ var _ = Describe("Synchronized Suite Nodes", func() { Describe("when proc 1 disappears before the proc 1 function returns", func() { It("fails and only runs the after suite", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() success, _ := RunFixture("happy-path", fixture) diff --git a/internal/internal_integration/table_test.go b/internal/internal_integration/table_test.go index a695ec3c4..6de5aaa73 100644 --- a/internal/internal_integration/table_test.go +++ b/internal/internal_integration/table_test.go @@ -291,12 +291,12 @@ var _ = Describe("Table driven tests", func() { }) }) - DescribeTable("it works when nils are passed in", func(a interface{}, b error) { + DescribeTable("it works when nils are passed in", func(a any, b error) { Ω(a).Should(BeNil()) Ω(b).Should(BeNil()) }, Entry("nils", nil, nil)) - DescribeTable("it supports variadic parameters", func(a int, b string, c ...interface{}) { + DescribeTable("it supports variadic parameters", func(a int, b string, c ...any) { Ω(a).Should(Equal(c[0])) Ω(b).Should(Equal(c[1])) Ω(c[2]).Should(BeNil()) @@ -427,7 +427,7 @@ var _ = Describe("Table driven tests", func() { Entry("A", 1), Entry("B", 2), Entry("C", 3), - Entry("D", []interface{}{FlakeAttempts(3), Offset(2)}, 3), + Entry("D", []any{FlakeAttempts(3), Offset(2)}, 3), ) }) Ω(success).Should(BeFalse()) @@ -469,7 +469,7 @@ var _ = Describe("Table driven tests", func() { Entry("A", 1), Entry("B", 2), Entry("C", 3), - Entry("D", []interface{}{MustPassRepeatedly(3), Offset(2)}, 3), + Entry("D", []any{MustPassRepeatedly(3), Offset(2)}, 3), ) }) Ω(success).Should(BeFalse()) diff --git a/internal/internal_suite_test.go b/internal/internal_suite_test.go index d0f162144..05d0c6845 100644 --- a/internal/internal_suite_test.go +++ b/internal/internal_suite_test.go @@ -35,9 +35,9 @@ type NestingLevel int // convenience helper to quickly make nodes // assumes they are correctly configured and no errors occur -func N(args ...interface{}) Node { +func N(args ...any) Node { nodeType, text, nestingLevel, hasBody := types.NodeTypeIt, "", -1, false - remainingArgs := []interface{}{cl} + remainingArgs := []any{cl} for _, arg := range args { switch t := reflect.TypeOf(arg); { case t == reflect.TypeOf(NestingLevel(1)): @@ -84,7 +84,7 @@ func S(nodes ...Node) Spec { } // convenience helper to quickly make code locations -func CL(options ...interface{}) types.CodeLocation { +func CL(options ...any) types.CodeLocation { cl = types.NewCodeLocation(1) for _, option := range options { if reflect.TypeOf(option).Kind() == reflect.String { diff --git a/internal/interrupt_handler/interrupt_handler.go b/internal/interrupt_handler/interrupt_handler.go index 8ed86111f..79bfa87db 100644 --- a/internal/interrupt_handler/interrupt_handler.go +++ b/internal/interrupt_handler/interrupt_handler.go @@ -40,7 +40,7 @@ func (ic InterruptCause) String() string { } type InterruptStatus struct { - Channel chan interface{} + Channel chan any Level InterruptLevel Cause InterruptCause } @@ -62,14 +62,14 @@ type InterruptHandlerInterface interface { } type InterruptHandler struct { - c chan interface{} + c chan any lock *sync.Mutex level InterruptLevel cause InterruptCause client parallel_support.Client - stop chan interface{} + stop chan any signals []os.Signal - requestAbortCheck chan interface{} + requestAbortCheck chan any } func NewInterruptHandler(client parallel_support.Client, signals ...os.Signal) *InterruptHandler { @@ -77,10 +77,10 @@ func NewInterruptHandler(client parallel_support.Client, signals ...os.Signal) * signals = []os.Signal{os.Interrupt, syscall.SIGTERM} } handler := &InterruptHandler{ - c: make(chan interface{}), + c: make(chan any), lock: &sync.Mutex{}, - stop: make(chan interface{}), - requestAbortCheck: make(chan interface{}), + stop: make(chan any), + requestAbortCheck: make(chan any), client: client, signals: signals, } @@ -98,9 +98,9 @@ func (handler *InterruptHandler) registerForInterrupts() { signal.Notify(signalChannel, handler.signals...) // cross-process abort handling - var abortChannel chan interface{} + var abortChannel chan any if handler.client != nil { - abortChannel = make(chan interface{}) + abortChannel = make(chan any) go func() { pollTicker := time.NewTicker(ABORT_POLLING_INTERVAL) for { @@ -125,7 +125,7 @@ func (handler *InterruptHandler) registerForInterrupts() { }() } - go func(abortChannel chan interface{}) { + go func(abortChannel chan any) { var interruptCause InterruptCause for { select { @@ -151,7 +151,7 @@ func (handler *InterruptHandler) registerForInterrupts() { } if handler.level != oldLevel { close(handler.c) - handler.c = make(chan interface{}) + handler.c = make(chan any) } handler.lock.Unlock() } diff --git a/internal/node.go b/internal/node.go index 14c7cf54e..179740da1 100644 --- a/internal/node.go +++ b/internal/node.go @@ -85,7 +85,7 @@ const SuppressProgressReporting = suppressProgressReporting(true) type FlakeAttempts uint type MustPassRepeatedly uint type Offset uint -type Done chan<- interface{} // Deprecated Done Channel for asynchronous testing +type Done chan<- any // Deprecated Done Channel for asynchronous testing type Labels []string type PollProgressInterval time.Duration type PollProgressAfter time.Duration @@ -111,9 +111,9 @@ func UnionOfLabels(labels ...Labels) Labels { return out } -func PartitionDecorations(args ...interface{}) ([]interface{}, []interface{}) { - decorations := []interface{}{} - remainingArgs := []interface{}{} +func PartitionDecorations(args ...any) ([]any, []any) { + decorations := []any{} + remainingArgs := []any{} for _, arg := range args { if isDecoration(arg) { decorations = append(decorations, arg) @@ -124,7 +124,7 @@ func PartitionDecorations(args ...interface{}) ([]interface{}, []interface{}) { return decorations, remainingArgs } -func isDecoration(arg interface{}) bool { +func isDecoration(arg any) bool { switch t := reflect.TypeOf(arg); { case t == nil: return false @@ -169,7 +169,7 @@ func isDecoration(arg interface{}) bool { } } -func isSliceOfDecorations(slice interface{}) bool { +func isSliceOfDecorations(slice any) bool { vSlice := reflect.ValueOf(slice) if vSlice.Len() == 0 { return false @@ -185,7 +185,7 @@ func isSliceOfDecorations(slice interface{}) bool { var contextType = reflect.TypeOf(new(context.Context)).Elem() var specContextType = reflect.TypeOf(new(SpecContext)).Elem() -func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeType, text string, args ...interface{}) (Node, []error) { +func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeType, text string, args ...any) (Node, []error) { baseOffset := 2 node := Node{ ID: UniqueNodeID(), @@ -208,7 +208,7 @@ func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeTy args = unrollInterfaceSlice(args) - remainingArgs := []interface{}{} + remainingArgs := []any{} //First get the CodeLocation up-to-date for _, arg := range args { switch v := arg.(type) { @@ -224,7 +224,7 @@ func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeTy labelsSeen := map[string]bool{} trackedFunctionError := false args = remainingArgs - remainingArgs = []interface{}{} + remainingArgs = []any{} //now process the rest of the args for _, arg := range args { switch t := reflect.TypeOf(arg); { @@ -439,7 +439,7 @@ func NewNode(deprecationTracker *types.DeprecationTracker, nodeType types.NodeTy var doneType = reflect.TypeOf(make(Done)) -func extractBodyFunction(deprecationTracker *types.DeprecationTracker, cl types.CodeLocation, arg interface{}) (func(SpecContext), bool) { +func extractBodyFunction(deprecationTracker *types.DeprecationTracker, cl types.CodeLocation, arg any) (func(SpecContext), bool) { t := reflect.TypeOf(arg) if t.NumOut() > 0 || t.NumIn() > 1 { return nil, false @@ -465,7 +465,7 @@ func extractBodyFunction(deprecationTracker *types.DeprecationTracker, cl types. var byteType = reflect.TypeOf([]byte{}) -func extractSynchronizedBeforeSuiteProc1Body(arg interface{}) (func(SpecContext) []byte, bool) { +func extractSynchronizedBeforeSuiteProc1Body(arg any) (func(SpecContext) []byte, bool) { t := reflect.TypeOf(arg) v := reflect.ValueOf(arg) @@ -493,7 +493,7 @@ func extractSynchronizedBeforeSuiteProc1Body(arg interface{}) (func(SpecContext) }, hasContext } -func extractSynchronizedBeforeSuiteAllProcsBody(arg interface{}) (func(SpecContext, []byte), bool) { +func extractSynchronizedBeforeSuiteAllProcsBody(arg any) (func(SpecContext, []byte), bool) { t := reflect.TypeOf(arg) v := reflect.ValueOf(arg) hasContext, hasByte := false, false @@ -524,11 +524,11 @@ func extractSynchronizedBeforeSuiteAllProcsBody(arg interface{}) (func(SpecConte var errInterface = reflect.TypeOf((*error)(nil)).Elem() -func NewCleanupNode(deprecationTracker *types.DeprecationTracker, fail func(string, types.CodeLocation), args ...interface{}) (Node, []error) { +func NewCleanupNode(deprecationTracker *types.DeprecationTracker, fail func(string, types.CodeLocation), args ...any) (Node, []error) { decorations, remainingArgs := PartitionDecorations(args...) baseOffset := 2 cl := types.NewCodeLocation(baseOffset) - finalArgs := []interface{}{} + finalArgs := []any{} for _, arg := range decorations { switch t := reflect.TypeOf(arg); { case t == reflect.TypeOf(Offset(0)): @@ -904,12 +904,12 @@ func (n Nodes) GetMaxMustPassRepeatedly() int { return maxMustPassRepeatedly } -func unrollInterfaceSlice(args interface{}) []interface{} { +func unrollInterfaceSlice(args any) []any { v := reflect.ValueOf(args) if v.Kind() != reflect.Slice { - return []interface{}{args} + return []any{args} } - out := []interface{}{} + out := []any{} for i := 0; i < v.Len(); i++ { el := reflect.ValueOf(v.Index(i).Interface()) if el.Kind() == reflect.Slice && el.Type() != reflect.TypeOf(Labels{}) { diff --git a/internal/node_test.go b/internal/node_test.go index 9a4a99093..b7b656960 100644 --- a/internal/node_test.go +++ b/internal/node_test.go @@ -43,21 +43,21 @@ var _ = Describe("Partitioning Decorations", func() { SpecTimeout(time.Second), nil, 1, - []interface{}{Focus, Pending, []interface{}{Offset(2), Serial, FlakeAttempts(2)}, Ordered, Label("a", "b", "c"), NodeTimeout(time.Second)}, - []interface{}{1, 2, 3.1, nil}, + []any{Focus, Pending, []any{Offset(2), Serial, FlakeAttempts(2)}, Ordered, Label("a", "b", "c"), NodeTimeout(time.Second)}, + []any{1, 2, 3.1, nil}, PollProgressInterval(time.Second), PollProgressAfter(time.Second), []string{"a", "b", "c"}, Label("A", "B", "C"), Label("D"), - []interface{}{}, + []any{}, FlakeAttempts(1), MustPassRepeatedly(1), true, OncePerOrdered, ) - Ω(decorations).Should(Equal([]interface{}{ + Ω(decorations).Should(Equal([]any{ Offset(3), types.NewCustomCodeLocation("hey there"), Focus, @@ -69,7 +69,7 @@ var _ = Describe("Partitioning Decorations", func() { NodeTimeout(time.Second), GracePeriod(time.Second), SpecTimeout(time.Second), - []interface{}{Focus, Pending, []interface{}{Offset(2), Serial, FlakeAttempts(2)}, Ordered, Label("a", "b", "c"), NodeTimeout(time.Second)}, + []any{Focus, Pending, []any{Offset(2), Serial, FlakeAttempts(2)}, Ordered, Label("a", "b", "c"), NodeTimeout(time.Second)}, PollProgressInterval(time.Second), PollProgressAfter(time.Second), Label("A", "B", "C"), @@ -79,15 +79,15 @@ var _ = Describe("Partitioning Decorations", func() { OncePerOrdered, })) - Ω(remaining).Should(Equal([]interface{}{ + Ω(remaining).Should(Equal([]any{ Foo{3}, "hey there", 2.0, nil, 1, - []interface{}{1, 2, 3.1, nil}, + []any{1, 2, 3.1, nil}, []string{"a", "b", "c"}, - []interface{}{}, + []any{}, true, })) }) @@ -425,7 +425,7 @@ var _ = Describe("Constructing nodes", func() { }) It("appends and dedupes all labels together, even if nested", func() { - node, errors := internal.NewNode(dt, ntIt, "text", body, Label("A", "B", "C"), Label("D", "E", "C"), []interface{}{Label("F"), []interface{}{Label("G", "H", "A", "F")}}) + node, errors := internal.NewNode(dt, ntIt, "text", body, Label("A", "B", "C"), Label("D", "E", "C"), []any{Label("F"), []any{Label("G", "H", "A", "F")}}) Ω(node.Labels).Should(Equal(Labels{"A", "B", "C", "D", "E", "F", "G", "H"})) ExpectAllWell(errors) }) @@ -481,7 +481,7 @@ var _ = Describe("Constructing nodes", func() { }) It("fails if a timeout is applied to a function that does not take a context", func() { - for _, decorator := range []interface{}{NodeTimeout(time.Second), SpecTimeout(time.Second), GracePeriod(time.Second)} { + for _, decorator := range []any{NodeTimeout(time.Second), SpecTimeout(time.Second), GracePeriod(time.Second)} { dt = types.NewDeprecationTracker() _, errors := internal.NewNode(dt, ntIt, "spec", func(_ SpecContext) {}, cl, decorator) Ω(errors).Should(BeEmpty()) @@ -592,7 +592,7 @@ var _ = Describe("Constructing nodes", func() { }) It("errors if the function takes one argument and that argument is not the deprecated Done channel, or a context", func() { - f := func(chan interface{}) {} + f := func(chan any) {} node, errors := internal.NewNode(dt, ntIt, "text", f, cl) Ω(node).Should(BeZero()) Ω(errors).Should(ConsistOf(types.GinkgoErrors.InvalidBodyType(reflect.TypeOf(f), cl, ntIt))) @@ -643,7 +643,7 @@ var _ = Describe("Constructing nodes", func() { Describe("when decorations are nested in slices", func() { It("unrolls them first", func() { - node, errors := internal.NewNode(dt, ntIt, "text", []interface{}{body, []interface{}{Focus, FlakeAttempts(3), Label("A")}, FlakeAttempts(2), Label("B"), Label("C", "D")}) + node, errors := internal.NewNode(dt, ntIt, "text", []any{body, []any{Focus, FlakeAttempts(3), Label("A")}, FlakeAttempts(2), Label("B"), Label("C", "D")}) Ω(node.FlakeAttempts).Should(Equal(2)) Ω(node.MarkedFocus).Should(BeTrue()) Ω(node.Labels).Should(Equal(Labels{"A", "B", "C", "D"})) diff --git a/internal/output_interceptor.go b/internal/output_interceptor.go index 4a1c09461..5598f15cb 100644 --- a/internal/output_interceptor.go +++ b/internal/output_interceptor.go @@ -69,7 +69,7 @@ type pipePair struct { writer *os.File } -func startPipeFactory(pipeChannel chan pipePair, shutdown chan interface{}) { +func startPipeFactory(pipeChannel chan pipePair, shutdown chan any) { for { //make the next pipe... pair := pipePair{} @@ -101,8 +101,8 @@ type genericOutputInterceptor struct { stderrClone *os.File pipe pipePair - shutdown chan interface{} - emergencyBailout chan interface{} + shutdown chan any + emergencyBailout chan any pipeChannel chan pipePair interceptedContent chan string @@ -139,7 +139,7 @@ func (interceptor *genericOutputInterceptor) ResumeIntercepting() { interceptor.intercepting = true if interceptor.stdoutClone == nil { interceptor.stdoutClone, interceptor.stderrClone = interceptor.implementation.CreateStdoutStderrClones() - interceptor.shutdown = make(chan interface{}) + interceptor.shutdown = make(chan any) go startPipeFactory(interceptor.pipeChannel, interceptor.shutdown) } @@ -147,13 +147,13 @@ func (interceptor *genericOutputInterceptor) ResumeIntercepting() { // we get the pipe from our pipe factory. it runs in the background so we can request the next pipe while the spec being intercepted is running interceptor.pipe = <-interceptor.pipeChannel - interceptor.emergencyBailout = make(chan interface{}) + interceptor.emergencyBailout = make(chan any) //Spin up a goroutine to copy data from the pipe into a buffer, this is how we capture any output the user is emitting go func() { buffer := &bytes.Buffer{} destination := io.MultiWriter(buffer, interceptor.forwardTo) - copyFinished := make(chan interface{}) + copyFinished := make(chan any) reader := interceptor.pipe.reader go func() { io.Copy(destination, reader) @@ -224,7 +224,7 @@ func NewOSGlobalReassigningOutputInterceptor() OutputInterceptor { return &genericOutputInterceptor{ interceptedContent: make(chan string), pipeChannel: make(chan pipePair), - shutdown: make(chan interface{}), + shutdown: make(chan any), implementation: &osGlobalReassigningOutputInterceptorImpl{}, } } diff --git a/internal/output_interceptor_unix.go b/internal/output_interceptor_unix.go index 8a237f446..e0f1431d5 100644 --- a/internal/output_interceptor_unix.go +++ b/internal/output_interceptor_unix.go @@ -13,7 +13,7 @@ func NewOutputInterceptor() OutputInterceptor { return &genericOutputInterceptor{ interceptedContent: make(chan string), pipeChannel: make(chan pipePair), - shutdown: make(chan interface{}), + shutdown: make(chan any), implementation: &dupSyscallOutputInterceptorImpl{}, } } diff --git a/internal/parallel_support/client_server.go b/internal/parallel_support/client_server.go index b3cd64292..4234d802c 100644 --- a/internal/parallel_support/client_server.go +++ b/internal/parallel_support/client_server.go @@ -30,7 +30,7 @@ type Server interface { Close() Address() string RegisterAlive(node int, alive func() bool) - GetSuiteDone() chan interface{} + GetSuiteDone() chan any GetOutputDestination() io.Writer SetOutputDestination(io.Writer) } diff --git a/internal/parallel_support/client_server_test.go b/internal/parallel_support/client_server_test.go index 4c91c43ee..73f2e80ec 100644 --- a/internal/parallel_support/client_server_test.go +++ b/internal/parallel_support/client_server_test.go @@ -216,10 +216,10 @@ var _ = Describe("The Parallel Support Client & Server", func() { }) Describe("Synchronization endpoints", func() { - var proc1Exited, proc2Exited, proc3Exited chan interface{} + var proc1Exited, proc2Exited, proc3Exited chan any BeforeEach(func() { - proc1Exited, proc2Exited, proc3Exited = make(chan interface{}), make(chan interface{}), make(chan interface{}) - aliveFunc := func(c chan interface{}) func() bool { + proc1Exited, proc2Exited, proc3Exited = make(chan any), make(chan any), make(chan any) + aliveFunc := func(c chan any) func() bool { return func() bool { select { case <-c: @@ -264,7 +264,7 @@ var _ = Describe("The Parallel Support Client & Server", func() { Context("when proc 1 hasn't responded yet", func() { It("blocks until it does", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() state, err := client.BlockUntilReportBeforeSuiteCompleted() @@ -332,7 +332,7 @@ var _ = Describe("The Parallel Support Client & Server", func() { Context("when proc 1 hasn't responded yet", func() { It("blocks until it does", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() state, data, err := client.BlockUntilSynchronizedBeforeSuiteData() @@ -350,7 +350,7 @@ var _ = Describe("The Parallel Support Client & Server", func() { Describe("BlockUntilNonprimaryProcsHaveFinished", func() { It("blocks until non-primary procs exit", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() Ω(client.BlockUntilNonprimaryProcsHaveFinished()).Should(Succeed()) @@ -376,7 +376,7 @@ var _ = Describe("The Parallel Support Client & Server", func() { }) It("blocks until all non-primary procs exit, then returns the aggregated report", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() report, err := client.BlockUntilAggregatedNonprimaryProcsReport() @@ -397,7 +397,7 @@ var _ = Describe("The Parallel Support Client & Server", func() { Context("when a non-primary proc disappears without reporting back", func() { It("blocks returns an appropriate error", func() { - done := make(chan interface{}) + done := make(chan any) go func() { defer GinkgoRecover() report, err := client.BlockUntilAggregatedNonprimaryProcsReport() diff --git a/internal/parallel_support/http_client.go b/internal/parallel_support/http_client.go index 6547c7a66..852587fe2 100644 --- a/internal/parallel_support/http_client.go +++ b/internal/parallel_support/http_client.go @@ -34,7 +34,7 @@ func (client *httpClient) Close() error { return nil } -func (client *httpClient) post(path string, data interface{}) error { +func (client *httpClient) post(path string, data any) error { var body io.Reader if data != nil { encoded, err := json.Marshal(data) @@ -54,7 +54,7 @@ func (client *httpClient) post(path string, data interface{}) error { return nil } -func (client *httpClient) poll(path string, data interface{}) error { +func (client *httpClient) poll(path string, data any) error { for { resp, err := http.Get(client.serverHost + path) if err != nil { diff --git a/internal/parallel_support/http_server.go b/internal/parallel_support/http_server.go index d2c71ab1b..8a1b7a5bb 100644 --- a/internal/parallel_support/http_server.go +++ b/internal/parallel_support/http_server.go @@ -75,7 +75,7 @@ func (server *httpServer) Address() string { return "http://" + server.listener.Addr().String() } -func (server *httpServer) GetSuiteDone() chan interface{} { +func (server *httpServer) GetSuiteDone() chan any { return server.handler.done } @@ -96,7 +96,7 @@ func (server *httpServer) RegisterAlive(node int, alive func() bool) { // // The server will forward all received messages to Ginkgo reporters registered with `RegisterReporters` -func (server *httpServer) decode(writer http.ResponseWriter, request *http.Request, object interface{}) bool { +func (server *httpServer) decode(writer http.ResponseWriter, request *http.Request, object any) bool { defer request.Body.Close() if json.NewDecoder(request.Body).Decode(object) != nil { writer.WriteHeader(http.StatusBadRequest) diff --git a/internal/parallel_support/rpc_client.go b/internal/parallel_support/rpc_client.go index 59e8e6fd0..bb4675a02 100644 --- a/internal/parallel_support/rpc_client.go +++ b/internal/parallel_support/rpc_client.go @@ -35,7 +35,7 @@ func (client *rpcClient) Close() error { return client.client.Close() } -func (client *rpcClient) poll(method string, data interface{}) error { +func (client *rpcClient) poll(method string, data any) error { for { err := client.client.Call(method, voidSender, data) if err == nil { diff --git a/internal/parallel_support/rpc_server.go b/internal/parallel_support/rpc_server.go index 2620fd562..1574f99ac 100644 --- a/internal/parallel_support/rpc_server.go +++ b/internal/parallel_support/rpc_server.go @@ -25,7 +25,7 @@ type RPCServer struct { handler *ServerHandler } -//Create a new server, automatically selecting a port +// Create a new server, automatically selecting a port func newRPCServer(parallelTotal int, reporter reporters.Reporter) (*RPCServer, error) { listener, err := net.Listen("tcp", "127.0.0.1:0") if err != nil { @@ -37,7 +37,7 @@ func newRPCServer(parallelTotal int, reporter reporters.Reporter) (*RPCServer, e }, nil } -//Start the server. You don't need to `go s.Start()`, just `s.Start()` +// Start the server. You don't need to `go s.Start()`, just `s.Start()` func (server *RPCServer) Start() { rpcServer := rpc.NewServer() rpcServer.RegisterName("Server", server.handler) //register the handler's methods as the server @@ -48,17 +48,17 @@ func (server *RPCServer) Start() { go httpServer.Serve(server.listener) } -//Stop the server +// Stop the server func (server *RPCServer) Close() { server.listener.Close() } -//The address the server can be reached it. Pass this into the `ForwardingReporter`. +// The address the server can be reached it. Pass this into the `ForwardingReporter`. func (server *RPCServer) Address() string { return server.listener.Addr().String() } -func (server *RPCServer) GetSuiteDone() chan interface{} { +func (server *RPCServer) GetSuiteDone() chan any { return server.handler.done } diff --git a/internal/parallel_support/server_handler.go b/internal/parallel_support/server_handler.go index a6d98793e..ab9e11372 100644 --- a/internal/parallel_support/server_handler.go +++ b/internal/parallel_support/server_handler.go @@ -18,7 +18,7 @@ var voidSender Void // It handles all the business logic to avoid duplication between the two servers type ServerHandler struct { - done chan interface{} + done chan any outputDestination io.Writer reporter reporters.Reporter alives []func() bool @@ -46,7 +46,7 @@ func newServerHandler(parallelTotal int, reporter reporters.Reporter) *ServerHan parallelTotal: parallelTotal, outputDestination: os.Stdout, - done: make(chan interface{}), + done: make(chan any), } } diff --git a/internal/report_entry.go b/internal/report_entry.go index cc351a39b..9c18dc8e5 100644 --- a/internal/report_entry.go +++ b/internal/report_entry.go @@ -8,7 +8,7 @@ import ( type ReportEntry = types.ReportEntry -func NewReportEntry(name string, cl types.CodeLocation, args ...interface{}) (ReportEntry, error) { +func NewReportEntry(name string, cl types.CodeLocation, args ...any) (ReportEntry, error) { out := ReportEntry{ Visibility: types.ReportEntryVisibilityAlways, Name: name, diff --git a/internal/report_entry_test.go b/internal/report_entry_test.go index 620c46948..08ffb7553 100644 --- a/internal/report_entry_test.go +++ b/internal/report_entry_test.go @@ -137,7 +137,7 @@ var _ = Describe("ReportEntry and ReportEntries", func() { It("round-trips through JSON correctly", func() { rtEntry := reportEntryJSONRoundTrip(reportEntry) - Ω(rtEntry.GetRawValue()).Should(Equal(map[string]interface{}{"Label": "bob", "Count": float64(17)})) + Ω(rtEntry.GetRawValue()).Should(Equal(map[string]any{"Label": "bob", "Count": float64(17)})) Ω(rtEntry.StringRepresentation()).Should(Equal("{Label:bob Count:17}")) }) @@ -165,7 +165,7 @@ var _ = Describe("ReportEntry and ReportEntries", func() { It("round-trips through JSON correctly", func() { rtEntry := reportEntryJSONRoundTrip(reportEntry) - Ω(rtEntry.GetRawValue()).Should(Equal(map[string]interface{}{"Label": "bob", "Count": float64(17)})) + Ω(rtEntry.GetRawValue()).Should(Equal(map[string]any{"Label": "bob", "Count": float64(17)})) Ω(rtEntry.StringRepresentation()).Should(Equal("bob 17")) }) }) @@ -186,7 +186,7 @@ var _ = Describe("ReportEntry and ReportEntries", func() { It("round-trips through JSON correctly", func() { rtEntry := reportEntryJSONRoundTrip(reportEntry) - Ω(rtEntry.GetRawValue()).Should(Equal(map[string]interface{}{"Label": "bob", "Count": float64(17)})) + Ω(rtEntry.GetRawValue()).Should(Equal(map[string]any{"Label": "bob", "Count": float64(17)})) Ω(rtEntry.StringRepresentation()).Should(Equal("{{red}}bob {{green}}17{{/}}")) }) }) diff --git a/internal/test_helpers/fake_interrupt_handler.go b/internal/test_helpers/fake_interrupt_handler.go index b217a7ffb..296af1412 100644 --- a/internal/test_helpers/fake_interrupt_handler.go +++ b/internal/test_helpers/fake_interrupt_handler.go @@ -7,7 +7,7 @@ import ( ) type FakeInterruptHandler struct { - c chan interface{} + c chan any lock *sync.Mutex level interrupt_handler.InterruptLevel cause interrupt_handler.InterruptCause @@ -17,7 +17,7 @@ type FakeInterruptHandler struct { func NewFakeInterruptHandler() *FakeInterruptHandler { handler := &FakeInterruptHandler{ - c: make(chan interface{}), + c: make(chan any), lock: &sync.Mutex{}, level: interrupt_handler.InterruptLevelUninterrupted, } @@ -32,7 +32,7 @@ func (handler *FakeInterruptHandler) Interrupt(cause interrupt_handler.Interrupt handler.level = interrupt_handler.InterruptLevelBailOut } else { close(handler.c) - handler.c = make(chan interface{}) + handler.c = make(chan any) } handler.lock.Unlock() } diff --git a/internal/test_helpers/fake_reporter.go b/internal/test_helpers/fake_reporter.go index 59a3145e6..1018d0d28 100644 --- a/internal/test_helpers/fake_reporter.go +++ b/internal/test_helpers/fake_reporter.go @@ -162,7 +162,7 @@ type NFailed int type NPending int type NFlaked int -func BeASuiteSummary(options ...interface{}) OmegaMatcher { +func BeASuiteSummary(options ...any) OmegaMatcher { type ReportStats struct { Succeeded bool TotalSpecs int @@ -224,7 +224,7 @@ type CapturedGinkgoWriterOutput string type CapturedStdOutput string type NumAttempts int -func HavePassed(options ...interface{}) OmegaMatcher { +func HavePassed(options ...any) OmegaMatcher { matchers := []OmegaMatcher{ HaveField("State", types.SpecStatePassed), HaveField("Failure", BeZero()), @@ -263,7 +263,7 @@ func HaveBeenSkipped() OmegaMatcher { ) } -func HaveBeenSkippedWithMessage(message string, options ...interface{}) OmegaMatcher { +func HaveBeenSkippedWithMessage(message string, options ...any) OmegaMatcher { matchers := []OmegaMatcher{ HaveField("State", types.SpecStateSkipped), HaveField("Failure.Message", Equal(message)), @@ -287,7 +287,7 @@ func HaveBeenInterrupted(cause interrupt_handler.InterruptCause) OmegaMatcher { type FailureNodeType types.NodeType -func failureMatcherForState(state types.SpecState, messageField string, options ...interface{}) OmegaMatcher { +func failureMatcherForState(state types.SpecState, messageField string, options ...any) OmegaMatcher { matchers := []OmegaMatcher{ HaveField("State", state), } @@ -323,19 +323,19 @@ func failureMatcherForState(state types.SpecState, messageField string, options return And(matchers...) } -func HaveFailed(options ...interface{}) OmegaMatcher { +func HaveFailed(options ...any) OmegaMatcher { return failureMatcherForState(types.SpecStateFailed, "Failure.Message", options...) } -func HaveTimedOut(options ...interface{}) OmegaMatcher { +func HaveTimedOut(options ...any) OmegaMatcher { return failureMatcherForState(types.SpecStateTimedout, "Failure.Message", options...) } -func HaveAborted(options ...interface{}) OmegaMatcher { +func HaveAborted(options ...any) OmegaMatcher { return failureMatcherForState(types.SpecStateAborted, "Failure.Message", options...) } -func HavePanicked(options ...interface{}) OmegaMatcher { +func HavePanicked(options ...any) OmegaMatcher { return failureMatcherForState(types.SpecStatePanicked, "Failure.ForwardedPanic", options...) } @@ -350,7 +350,7 @@ func TLWithOffset[O int | string](o O) types.TimelineLocation { return t } -func BeSpecEvent(options ...interface{}) OmegaMatcher { +func BeSpecEvent(options ...any) OmegaMatcher { description := []string{"BeSpecEvent"} matchers := []OmegaMatcher{} for _, option := range options { @@ -385,7 +385,7 @@ func BeSpecEvent(options ...interface{}) OmegaMatcher { return OmegaMatcherWithDescription{OmegaMatcher: And(matchers...), Description: strings.Join(description, " ")} } -func BeProgressReport(options ...interface{}) OmegaMatcher { +func BeProgressReport(options ...any) OmegaMatcher { description := []string{"BeProgressReport"} matchers := []OmegaMatcher{} for _, option := range options { @@ -411,7 +411,7 @@ func BeProgressReport(options ...interface{}) OmegaMatcher { return OmegaMatcherWithDescription{OmegaMatcher: And(matchers...), Description: strings.Join(description, " ")} } -func BeReportEntry(options ...interface{}) OmegaMatcher { +func BeReportEntry(options ...any) OmegaMatcher { description := []string{"BeReportEntry"} matchers := []OmegaMatcher{} for _, option := range options { diff --git a/internal/test_helpers/run_tracker.go b/internal/test_helpers/run_tracker.go index 24069d69e..1c5f66760 100644 --- a/internal/test_helpers/run_tracker.go +++ b/internal/test_helpers/run_tracker.go @@ -20,13 +20,13 @@ RunTracker tracks invocations of functions - useful to assert orders in which no type RunTracker struct { lock *sync.Mutex trackedRuns []string - trackedData map[string]map[string]interface{} + trackedData map[string]map[string]any } func NewRunTracker() *RunTracker { return &RunTracker{ lock: &sync.Mutex{}, - trackedData: map[string]map[string]interface{}{}, + trackedData: map[string]map[string]any{}, } } @@ -42,11 +42,11 @@ func (rt *RunTracker) Run(text string) { rt.trackedRuns = append(rt.trackedRuns, text) } -func (rt *RunTracker) RunWithData(text string, kv ...interface{}) { +func (rt *RunTracker) RunWithData(text string, kv ...any) { rt.lock.Lock() defer rt.lock.Unlock() rt.trackedRuns = append(rt.trackedRuns, text) - data := map[string]interface{}{} + data := map[string]any{} for i := 0; i < len(kv); i += 2 { key := kv[i].(string) value := kv[i+1] @@ -63,7 +63,7 @@ func (rt *RunTracker) TrackedRuns() []string { return trackedRuns } -func (rt *RunTracker) DataFor(text string) map[string]interface{} { +func (rt *RunTracker) DataFor(text string) map[string]any { rt.lock.Lock() defer rt.lock.Unlock() return rt.trackedData[text] @@ -102,14 +102,14 @@ func HaveRun(run string) OmegaMatcher { }, ContainElement(run)) } -func HaveRunWithData(run string, kv ...interface{}) OmegaMatcher { +func HaveRunWithData(run string, kv ...any) OmegaMatcher { matchers := []types.GomegaMatcher{} for i := 0; i < len(kv); i += 2 { matchers = append(matchers, HaveKeyWithValue(kv[i], kv[i+1])) } return And( HaveRun(run), - WithTransform(func(rt *RunTracker) map[string]interface{} { + WithTransform(func(rt *RunTracker) map[string]any { return rt.DataFor(run) }, And(matchers...)), ) @@ -126,7 +126,7 @@ type HaveTrackedMatcher struct { message string } -func (m *HaveTrackedMatcher) Match(actual interface{}) (bool, error) { +func (m *HaveTrackedMatcher) Match(actual any) (bool, error) { rt, ok := actual.(*RunTracker) if !ok { return false, fmt.Errorf("HaveTracked() must be passed a RunTracker - got %T instead", actual) @@ -159,11 +159,11 @@ func (m *HaveTrackedMatcher) Match(actual interface{}) (bool, error) { return success, nil } -func (m *HaveTrackedMatcher) FailureMessage(actual interface{}) string { +func (m *HaveTrackedMatcher) FailureMessage(actual any) string { return "Expected runs did not match tracked runs:\n" + formatter.F(m.message) } -func (m *HaveTrackedMatcher) NegatedFailureMessage(actual interface{}) string { +func (m *HaveTrackedMatcher) NegatedFailureMessage(actual any) string { return "Expected runs matched tracked runs:\n" + formatter.F(m.message) } diff --git a/internal/test_helpers/set_up_server.go b/internal/test_helpers/set_up_server.go index 0f750ecc4..27ea06ec0 100644 --- a/internal/test_helpers/set_up_server.go +++ b/internal/test_helpers/set_up_server.go @@ -7,16 +7,16 @@ import ( . "github.com/onsi/gomega" ) -func SetUpServerAndClient(numNodes int) (parallel_support.Server, parallel_support.Client, map[int]chan interface{}) { +func SetUpServerAndClient(numNodes int) (parallel_support.Server, parallel_support.Client, map[int]chan any) { server, err := parallel_support.NewServer(numNodes, reporters.NoopReporter{}) Ω(err).ShouldNot(HaveOccurred()) server.Start() client := parallel_support.NewClient(server.Address()) Eventually(client.Connect).Should(BeTrue()) - exitChannels := map[int]chan interface{}{} + exitChannels := map[int]chan any{} for node := 1; node <= numNodes; node++ { - c := make(chan interface{}) + c := make(chan any) exitChannels[node] = c server.RegisterAlive(node, func() bool { select { diff --git a/internal/testingtproxy/testing_t_proxy.go b/internal/testingtproxy/testing_t_proxy.go index 73e265565..2890da03b 100644 --- a/internal/testingtproxy/testing_t_proxy.go +++ b/internal/testingtproxy/testing_t_proxy.go @@ -19,9 +19,9 @@ type addReportEntryFunc func(names string, args ...any) type ginkgoWriterInterface interface { io.Writer - Print(a ...interface{}) - Printf(format string, a ...interface{}) - Println(a ...interface{}) + Print(a ...any) + Printf(format string, a ...any) + Println(a ...any) } type ginkgoRecoverFunc func() type attachProgressReporterFunc func(func() string) func() @@ -80,11 +80,11 @@ func (t *ginkgoTestingTProxy) Setenv(key, value string) { } } -func (t *ginkgoTestingTProxy) Error(args ...interface{}) { +func (t *ginkgoTestingTProxy) Error(args ...any) { t.fail(fmt.Sprintln(args...), t.offset) } -func (t *ginkgoTestingTProxy) Errorf(format string, args ...interface{}) { +func (t *ginkgoTestingTProxy) Errorf(format string, args ...any) { t.fail(fmt.Sprintf(format, args...), t.offset) } @@ -100,11 +100,11 @@ func (t *ginkgoTestingTProxy) Failed() bool { return t.report().Failed() } -func (t *ginkgoTestingTProxy) Fatal(args ...interface{}) { +func (t *ginkgoTestingTProxy) Fatal(args ...any) { t.fail(fmt.Sprintln(args...), t.offset) } -func (t *ginkgoTestingTProxy) Fatalf(format string, args ...interface{}) { +func (t *ginkgoTestingTProxy) Fatalf(format string, args ...any) { t.fail(fmt.Sprintf(format, args...), t.offset) } @@ -112,11 +112,11 @@ func (t *ginkgoTestingTProxy) Helper() { types.MarkAsHelper(1) } -func (t *ginkgoTestingTProxy) Log(args ...interface{}) { +func (t *ginkgoTestingTProxy) Log(args ...any) { fmt.Fprintln(t.writer, args...) } -func (t *ginkgoTestingTProxy) Logf(format string, args ...interface{}) { +func (t *ginkgoTestingTProxy) Logf(format string, args ...any) { t.Log(fmt.Sprintf(format, args...)) } @@ -128,7 +128,7 @@ func (t *ginkgoTestingTProxy) Parallel() { // No-op } -func (t *ginkgoTestingTProxy) Skip(args ...interface{}) { +func (t *ginkgoTestingTProxy) Skip(args ...any) { t.skip(fmt.Sprintln(args...), t.offset) } @@ -136,7 +136,7 @@ func (t *ginkgoTestingTProxy) SkipNow() { t.skip("skip", t.offset) } -func (t *ginkgoTestingTProxy) Skipf(format string, args ...interface{}) { +func (t *ginkgoTestingTProxy) Skipf(format string, args ...any) { t.skip(fmt.Sprintf(format, args...), t.offset) } diff --git a/internal/writer.go b/internal/writer.go index 574f172df..698e336e3 100644 --- a/internal/writer.go +++ b/internal/writer.go @@ -121,15 +121,15 @@ func (w *Writer) ClearTeeWriters() { w.teeWriters = []io.Writer{} } -func (w *Writer) Print(a ...interface{}) { +func (w *Writer) Print(a ...any) { fmt.Fprint(w, a...) } -func (w *Writer) Printf(format string, a ...interface{}) { +func (w *Writer) Printf(format string, a ...any) { fmt.Fprintf(w, format, a...) } -func (w *Writer) Println(a ...interface{}) { +func (w *Writer) Println(a ...any) { fmt.Fprintln(w, a...) } diff --git a/reporters/default_reporter.go b/reporters/default_reporter.go index 56b7be758..a0211c516 100644 --- a/reporters/default_reporter.go +++ b/reporters/default_reporter.go @@ -656,11 +656,11 @@ func (r *DefaultReporter) _emit(s string, block bool, isDelimiter bool) { } /* Rendering text */ -func (r *DefaultReporter) f(format string, args ...interface{}) string { +func (r *DefaultReporter) f(format string, args ...any) string { return r.formatter.F(format, args...) } -func (r *DefaultReporter) fi(indentation uint, format string, args ...interface{}) string { +func (r *DefaultReporter) fi(indentation uint, format string, args ...any) string { return r.formatter.Fi(indentation, format, args...) } diff --git a/reporters/default_reporter_test.go b/reporters/default_reporter_test.go index 27d357159..d26262571 100644 --- a/reporters/default_reporter_test.go +++ b/reporters/default_reporter_test.go @@ -45,7 +45,7 @@ var FORMATTED_TIME = PLACEHOLDER_TIME.Format(types.GINKGO_TIME_FORMAT) var tlOrder = 1 -func TL(options ...interface{}) types.TimelineLocation { +func TL(options ...any) types.TimelineLocation { out := types.TimelineLocation{ Order: tlOrder, Time: now, @@ -65,7 +65,7 @@ func TL(options ...interface{}) types.TimelineLocation { } // convenience helper to quickly make Failures -func F(options ...interface{}) types.Failure { +func F(options ...any) types.Failure { failure := types.Failure{TimelineLocation: TL()} for _, option := range options { switch x := option.(type) { @@ -94,7 +94,7 @@ func F(options ...interface{}) types.Failure { return failure } -func AF(state types.SpecState, options ...interface{}) types.AdditionalFailure { +func AF(state types.SpecState, options ...any) types.AdditionalFailure { return types.AdditionalFailure{ State: state, Failure: F(options...), @@ -105,7 +105,7 @@ type STD string type GW string // convenience helper to quickly make SpecReports -func S(options ...interface{}) types.SpecReport { +func S(options ...any) types.SpecReport { report := types.SpecReport{ LeafNodeType: types.NodeTypeIt, State: types.SpecStatePassed, @@ -252,7 +252,7 @@ type CurrentStepText string type LeafNodeText string type AdditionalReports []string -func PR(options ...interface{}) types.ProgressReport { +func PR(options ...any) types.ProgressReport { report := types.ProgressReport{ ParallelProcess: 1, RunningInParallel: false, @@ -299,7 +299,7 @@ func PR(options ...interface{}) types.ProgressReport { return report } -func Fn(f string, filename string, line int, options ...interface{}) types.FunctionCall { +func Fn(f string, filename string, line int, options ...any) types.FunctionCall { out := types.FunctionCall{ Function: f, Filename: filename, @@ -319,7 +319,7 @@ func Fn(f string, filename string, line int, options ...interface{}) types.Funct return out } -func G(options ...interface{}) types.Goroutine { +func G(options ...any) types.Goroutine { goroutine := types.Goroutine{ ID: 17, State: "running", @@ -342,7 +342,7 @@ func G(options ...interface{}) types.Goroutine { return goroutine } -func RE(name string, cl types.CodeLocation, args ...interface{}) types.ReportEntry { +func RE(name string, cl types.CodeLocation, args ...any) types.ReportEntry { var tl = TL() finalArgs := []any{} for _, arg := range args { @@ -358,7 +358,7 @@ func RE(name string, cl types.CodeLocation, args ...interface{}) types.ReportEnt return entry } -func SE(options ...interface{}) types.SpecEvent { +func SE(options ...any) types.SpecEvent { se := types.SpecEvent{TimelineLocation: TL()} for _, option := range options { switch x := option.(type) { diff --git a/reporting_dsl.go b/reporting_dsl.go index f33786a2d..4b3ae0ae8 100644 --- a/reporting_dsl.go +++ b/reporting_dsl.go @@ -60,7 +60,7 @@ AddReportEntry() must be called within a Subject or Setup node - not in a Contai You can learn more about Report Entries here: https://onsi.github.io/ginkgo/#attaching-data-to-reports */ -func AddReportEntry(name string, args ...interface{}) { +func AddReportEntry(name string, args ...any) { cl := types.NewCodeLocation(1) reportEntry, err := internal.NewReportEntry(name, cl, args...) if err != nil { @@ -79,8 +79,8 @@ receives a SpecReport. They are called before the spec starts. You cannot nest any other Ginkgo nodes within a ReportBeforeEach node's closure. You can learn more about ReportBeforeEach here: https://onsi.github.io/ginkgo/#generating-reports-programmatically */ -func ReportBeforeEach(body func(SpecReport), args ...interface{}) bool { - combinedArgs := []interface{}{body} +func ReportBeforeEach(body func(SpecReport), args ...any) bool { + combinedArgs := []any{body} combinedArgs = append(combinedArgs, args...) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeReportBeforeEach, "", combinedArgs...)) @@ -93,8 +93,8 @@ receives a SpecReport. They are called after the spec has completed and receive You cannot nest any other Ginkgo nodes within a ReportAfterEach node's closure. You can learn more about ReportAfterEach here: https://onsi.github.io/ginkgo/#generating-reports-programmatically */ -func ReportAfterEach(body func(SpecReport), args ...interface{}) bool { - combinedArgs := []interface{}{body} +func ReportAfterEach(body func(SpecReport), args ...any) bool { + combinedArgs := []any{body} combinedArgs = append(combinedArgs, args...) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeReportAfterEach, "", combinedArgs...)) @@ -113,8 +113,8 @@ You can learn more about ReportAfterSuite here: https://onsi.github.io/ginkgo/#g You can learn more about Ginkgo's reporting infrastructure, including generating reports with the CLI here: https://onsi.github.io/ginkgo/#generating-machine-readable-reports */ -func ReportBeforeSuite(body func(Report), args ...interface{}) bool { - combinedArgs := []interface{}{body} +func ReportBeforeSuite(body func(Report), args ...any) bool { + combinedArgs := []any{body} combinedArgs = append(combinedArgs, args...) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeReportBeforeSuite, "", combinedArgs...)) } @@ -135,8 +135,8 @@ You can learn more about ReportAfterSuite here: https://onsi.github.io/ginkgo/#g You can learn more about Ginkgo's reporting infrastructure, including generating reports with the CLI here: https://onsi.github.io/ginkgo/#generating-machine-readable-reports */ -func ReportAfterSuite(text string, body func(Report), args ...interface{}) bool { - combinedArgs := []interface{}{body} +func ReportAfterSuite(text string, body func(Report), args ...any) bool { + combinedArgs := []any{body} combinedArgs = append(combinedArgs, args...) return pushNode(internal.NewNode(deprecationTracker, types.NodeTypeReportAfterSuite, text, combinedArgs...)) } diff --git a/table_dsl.go b/table_dsl.go index ac9b7abb5..38dab2f08 100644 --- a/table_dsl.go +++ b/table_dsl.go @@ -23,7 +23,7 @@ You can learn more about generating EntryDescriptions here: https://onsi.github. */ type EntryDescription string -func (ed EntryDescription) render(args ...interface{}) string { +func (ed EntryDescription) render(args ...any) string { return fmt.Sprintf(string(ed), args...) } @@ -44,7 +44,7 @@ For example: You can learn more about DescribeTable here: https://onsi.github.io/ginkgo/#table-specs And can explore some Table patterns here: https://onsi.github.io/ginkgo/#table-specs-patterns */ -func DescribeTable(description string, args ...interface{}) bool { +func DescribeTable(description string, args ...any) bool { GinkgoHelper() generateTable(description, args...) return true @@ -53,7 +53,7 @@ func DescribeTable(description string, args ...interface{}) bool { /* You can focus a table with `FDescribeTable`. This is equivalent to `FDescribe`. */ -func FDescribeTable(description string, args ...interface{}) bool { +func FDescribeTable(description string, args ...any) bool { GinkgoHelper() args = append(args, internal.Focus) generateTable(description, args...) @@ -63,7 +63,7 @@ func FDescribeTable(description string, args ...interface{}) bool { /* You can mark a table as pending with `PDescribeTable`. This is equivalent to `PDescribe`. */ -func PDescribeTable(description string, args ...interface{}) bool { +func PDescribeTable(description string, args ...any) bool { GinkgoHelper() args = append(args, internal.Pending) generateTable(description, args...) @@ -79,9 +79,9 @@ var XDescribeTable = PDescribeTable TableEntry represents an entry in a table test. You generally use the `Entry` constructor. */ type TableEntry struct { - description interface{} - decorations []interface{} - parameters []interface{} + description any + decorations []any + parameters []any codeLocation types.CodeLocation } @@ -97,7 +97,7 @@ If you want to generate interruptible specs simply write a Table function that a You can learn more about Entry here: https://onsi.github.io/ginkgo/#table-specs */ -func Entry(description interface{}, args ...interface{}) TableEntry { +func Entry(description any, args ...any) TableEntry { GinkgoHelper() decorations, parameters := internal.PartitionDecorations(args...) return TableEntry{description: description, decorations: decorations, parameters: parameters, codeLocation: types.NewCodeLocation(0)} @@ -106,7 +106,7 @@ func Entry(description interface{}, args ...interface{}) TableEntry { /* You can focus a particular entry with FEntry. This is equivalent to FIt. */ -func FEntry(description interface{}, args ...interface{}) TableEntry { +func FEntry(description any, args ...any) TableEntry { GinkgoHelper() decorations, parameters := internal.PartitionDecorations(args...) decorations = append(decorations, internal.Focus) @@ -116,7 +116,7 @@ func FEntry(description interface{}, args ...interface{}) TableEntry { /* You can mark a particular entry as pending with PEntry. This is equivalent to PIt. */ -func PEntry(description interface{}, args ...interface{}) TableEntry { +func PEntry(description any, args ...any) TableEntry { GinkgoHelper() decorations, parameters := internal.PartitionDecorations(args...) decorations = append(decorations, internal.Pending) @@ -131,17 +131,17 @@ var XEntry = PEntry var contextType = reflect.TypeOf(new(context.Context)).Elem() var specContextType = reflect.TypeOf(new(SpecContext)).Elem() -func generateTable(description string, args ...interface{}) { +func generateTable(description string, args ...any) { GinkgoHelper() cl := types.NewCodeLocation(0) - containerNodeArgs := []interface{}{cl} + containerNodeArgs := []any{cl} entries := []TableEntry{} - var itBody interface{} + var itBody any var itBodyType reflect.Type - var tableLevelEntryDescription interface{} - tableLevelEntryDescription = func(args ...interface{}) string { + var tableLevelEntryDescription any + tableLevelEntryDescription = func(args ...any) string { out := []string{} for _, arg := range args { out = append(out, fmt.Sprint(arg)) @@ -200,7 +200,7 @@ func generateTable(description string, args ...interface{}) { err = types.GinkgoErrors.InvalidEntryDescription(entry.codeLocation) } - itNodeArgs := []interface{}{entry.codeLocation} + itNodeArgs := []any{entry.codeLocation} itNodeArgs = append(itNodeArgs, entry.decorations...) hasContext := false @@ -221,7 +221,7 @@ func generateTable(description string, args ...interface{}) { if err != nil { panic(err) } - invokeFunction(itBody, append([]interface{}{c}, entry.parameters...)) + invokeFunction(itBody, append([]any{c}, entry.parameters...)) }) } else { itNodeArgs = append(itNodeArgs, func() { @@ -239,7 +239,7 @@ func generateTable(description string, args ...interface{}) { pushNode(internal.NewNode(deprecationTracker, types.NodeTypeContainer, description, containerNodeArgs...)) } -func invokeFunction(function interface{}, parameters []interface{}) []reflect.Value { +func invokeFunction(function any, parameters []any) []reflect.Value { inValues := make([]reflect.Value, len(parameters)) funcType := reflect.TypeOf(function) @@ -262,7 +262,7 @@ func invokeFunction(function interface{}, parameters []interface{}) []reflect.Va return reflect.ValueOf(function).Call(inValues) } -func validateParameters(function interface{}, parameters []interface{}, kind string, cl types.CodeLocation, hasContext bool) error { +func validateParameters(function any, parameters []any, kind string, cl types.CodeLocation, hasContext bool) error { funcType := reflect.TypeOf(function) limit := funcType.NumIn() offset := 0 @@ -300,7 +300,7 @@ func validateParameters(function interface{}, parameters []interface{}, kind str return nil } -func computeValue(parameter interface{}, t reflect.Type) reflect.Value { +func computeValue(parameter any, t reflect.Type) reflect.Value { if parameter == nil { return reflect.Zero(t) } else { diff --git a/types/config.go b/types/config.go index 1014c7b49..3182ea6ab 100644 --- a/types/config.go +++ b/types/config.go @@ -350,7 +350,7 @@ var ReporterConfigFlags = GinkgoFlags{ func BuildTestSuiteFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterConfig) (GinkgoFlagSet, error) { flags := SuiteConfigFlags.CopyAppend(ParallelConfigFlags...).CopyAppend(ReporterConfigFlags...) flags = flags.WithPrefix("ginkgo") - bindings := map[string]interface{}{ + bindings := map[string]any{ "S": suiteConfig, "R": reporterConfig, "D": &deprecatedConfig{}, @@ -627,7 +627,7 @@ func GenerateGoTestCompileArgs(goFlagsConfig GoFlagsConfig, destination string, args := []string{"test", "-c", "-o", destination, packageToBuild} goArgs, err := GenerateFlagArgs( GoBuildFlags, - map[string]interface{}{ + map[string]any{ "Go": &goFlagsConfig, }, ) @@ -646,7 +646,7 @@ func GenerateGinkgoTestRunArgs(suiteConfig SuiteConfig, reporterConfig ReporterC flags = flags.CopyAppend(ParallelConfigFlags.WithPrefix("ginkgo")...) flags = flags.CopyAppend(ReporterConfigFlags.WithPrefix("ginkgo")...) flags = flags.CopyAppend(GoRunFlags.WithPrefix("test")...) - bindings := map[string]interface{}{ + bindings := map[string]any{ "S": &suiteConfig, "R": &reporterConfig, "Go": &goFlagsConfig, @@ -658,7 +658,7 @@ func GenerateGinkgoTestRunArgs(suiteConfig SuiteConfig, reporterConfig ReporterC // GenerateGoTestRunArgs is used by the Ginkgo CLI to generate command line arguments to pass to the compiled non-Ginkgo test binary func GenerateGoTestRunArgs(goFlagsConfig GoFlagsConfig) ([]string, error) { flags := GoRunFlags.WithPrefix("test") - bindings := map[string]interface{}{ + bindings := map[string]any{ "Go": &goFlagsConfig, } @@ -680,7 +680,7 @@ func BuildRunCommandFlagSet(suiteConfig *SuiteConfig, reporterConfig *ReporterCo flags = flags.CopyAppend(GoBuildFlags...) flags = flags.CopyAppend(GoRunFlags...) - bindings := map[string]interface{}{ + bindings := map[string]any{ "S": suiteConfig, "R": reporterConfig, "C": cliConfig, @@ -701,7 +701,7 @@ func BuildWatchCommandFlagSet(suiteConfig *SuiteConfig, reporterConfig *Reporter flags = flags.CopyAppend(GoBuildFlags...) flags = flags.CopyAppend(GoRunFlags...) - bindings := map[string]interface{}{ + bindings := map[string]any{ "S": suiteConfig, "R": reporterConfig, "C": cliConfig, @@ -717,7 +717,7 @@ func BuildBuildCommandFlagSet(cliConfig *CLIConfig, goFlagsConfig *GoFlagsConfig flags := GinkgoCLISharedFlags flags = flags.CopyAppend(GoBuildFlags...) - bindings := map[string]interface{}{ + bindings := map[string]any{ "C": cliConfig, "Go": goFlagsConfig, "D": &deprecatedConfig{}, @@ -741,7 +741,7 @@ func BuildBuildCommandFlagSet(cliConfig *CLIConfig, goFlagsConfig *GoFlagsConfig func BuildLabelsCommandFlagSet(cliConfig *CLIConfig) (GinkgoFlagSet, error) { flags := GinkgoCLISharedFlags.SubsetWithNames("r", "skip-package") - bindings := map[string]interface{}{ + bindings := map[string]any{ "C": cliConfig, } diff --git a/types/deprecated_types.go b/types/deprecated_types.go index 17922304b..518989a84 100644 --- a/types/deprecated_types.go +++ b/types/deprecated_types.go @@ -113,7 +113,7 @@ type DeprecatedSpecFailure struct { type DeprecatedSpecMeasurement struct { Name string - Info interface{} + Info any Order int Results []float64 diff --git a/types/errors.go b/types/errors.go index 1e0dbfd9d..c0657d891 100644 --- a/types/errors.go +++ b/types/errors.go @@ -88,7 +88,7 @@ body of a {{bold}}Describe{{/}}, {{bold}}Context{{/}}, or {{bold}}When{{/}}.`, n } } -func (g ginkgoErrors) CaughtPanicDuringABuildPhase(caughtPanic interface{}, cl CodeLocation) error { +func (g ginkgoErrors) CaughtPanicDuringABuildPhase(caughtPanic any, cl CodeLocation) error { return GinkgoError{ Heading: "Assertion or Panic detected during tree construction", Message: formatter.F( @@ -189,7 +189,7 @@ func (g ginkgoErrors) InvalidDeclarationOfFlakeAttemptsAndMustPassRepeatedly(cl } } -func (g ginkgoErrors) UnknownDecorator(cl CodeLocation, nodeType NodeType, decorator interface{}) error { +func (g ginkgoErrors) UnknownDecorator(cl CodeLocation, nodeType NodeType, decorator any) error { return GinkgoError{ Heading: "Unknown Decorator", Message: formatter.F(`[%s] node was passed an unknown decorator: '%#v'`, nodeType, decorator), @@ -345,7 +345,7 @@ func (g ginkgoErrors) PushingCleanupInCleanupNode(cl CodeLocation) error { } /* ReportEntry errors */ -func (g ginkgoErrors) TooManyReportEntryValues(cl CodeLocation, arg interface{}) error { +func (g ginkgoErrors) TooManyReportEntryValues(cl CodeLocation, arg any) error { return GinkgoError{ Heading: "Too Many ReportEntry Values", Message: formatter.F(`{{bold}}AddGinkgoReport{{/}} can only be given one value. Got unexpected value: %#v`, arg), @@ -530,7 +530,7 @@ func (g ginkgoErrors) SynchronizedBeforeSuiteDisappearedOnProc1() error { /* Configuration errors */ -func (g ginkgoErrors) UnknownTypePassedToRunSpecs(value interface{}) error { +func (g ginkgoErrors) UnknownTypePassedToRunSpecs(value any) error { return GinkgoError{ Heading: "Unknown Type passed to RunSpecs", Message: fmt.Sprintf("RunSpecs() accepts labels, and configuration of type types.SuiteConfig and/or types.ReporterConfig.\n You passed in: %v", value), diff --git a/types/file_filters_test.go b/types/file_filters_test.go index fbd8da837..761d0157b 100644 --- a/types/file_filters_test.go +++ b/types/file_filters_test.go @@ -26,7 +26,7 @@ var _ = Describe("FileFilters", func() { ) DescribeTable("Successful cases", - func(matches bool, filters []string, clsArgs ...interface{}) { + func(matches bool, filters []string, clsArgs ...any) { ffs, err := types.ParseFileFilters(filters) Ω(err).ShouldNot(HaveOccurred()) @@ -45,7 +45,7 @@ var _ = Describe("FileFilters", func() { Ω(ffs.Matches(cls)).Should(BeFalse()) } }, - func(matches bool, filters []string, clsArgs ...interface{}) string { + func(matches bool, filters []string, clsArgs ...any) string { return "When the filters are " + strings.Join(filters, " | ") }, //without line numbers diff --git a/types/flags.go b/types/flags.go index 9186ae873..8c0af7d58 100644 --- a/types/flags.go +++ b/types/flags.go @@ -91,7 +91,7 @@ func (gfs GinkgoFlagSections) Lookup(key string) (GinkgoFlagSection, bool) { type GinkgoFlagSet struct { flags GinkgoFlags - bindings interface{} + bindings any sections GinkgoFlagSections extraGoFlagsSection GinkgoFlagSection @@ -100,7 +100,7 @@ type GinkgoFlagSet struct { } // Call NewGinkgoFlagSet to create GinkgoFlagSet that creates and binds to it's own *flag.FlagSet -func NewGinkgoFlagSet(flags GinkgoFlags, bindings interface{}, sections GinkgoFlagSections) (GinkgoFlagSet, error) { +func NewGinkgoFlagSet(flags GinkgoFlags, bindings any, sections GinkgoFlagSections) (GinkgoFlagSet, error) { return bindFlagSet(GinkgoFlagSet{ flags: flags, bindings: bindings, @@ -109,7 +109,7 @@ func NewGinkgoFlagSet(flags GinkgoFlags, bindings interface{}, sections GinkgoFl } // Call NewGinkgoFlagSet to create GinkgoFlagSet that extends an existing *flag.FlagSet -func NewAttachedGinkgoFlagSet(flagSet *flag.FlagSet, flags GinkgoFlags, bindings interface{}, sections GinkgoFlagSections, extraGoFlagsSection GinkgoFlagSection) (GinkgoFlagSet, error) { +func NewAttachedGinkgoFlagSet(flagSet *flag.FlagSet, flags GinkgoFlags, bindings any, sections GinkgoFlagSections, extraGoFlagsSection GinkgoFlagSection) (GinkgoFlagSet, error) { return bindFlagSet(GinkgoFlagSet{ flags: flags, bindings: bindings, @@ -334,7 +334,7 @@ func (f GinkgoFlagSet) substituteUsage() { fmt.Fprintln(f.flagSet.Output(), f.Usage()) } -func valueAtKeyPath(root interface{}, keyPath string) (reflect.Value, bool) { +func valueAtKeyPath(root any, keyPath string) (reflect.Value, bool) { if len(keyPath) == 0 { return reflect.Value{}, false } @@ -431,8 +431,8 @@ func (ssv stringSliceVar) Set(s string) error { return nil } -//given a set of GinkgoFlags and bindings, generate flag arguments suitable to be passed to an application with that set of flags configured. -func GenerateFlagArgs(flags GinkgoFlags, bindings interface{}) ([]string, error) { +// given a set of GinkgoFlags and bindings, generate flag arguments suitable to be passed to an application with that set of flags configured. +func GenerateFlagArgs(flags GinkgoFlags, bindings any) ([]string, error) { result := []string{} for _, flag := range flags { name := flag.ExportAs diff --git a/types/flags_test.go b/types/flags_test.go index 17d52ad28..83dde9397 100644 --- a/types/flags_test.go +++ b/types/flags_test.go @@ -115,7 +115,7 @@ var _ = Describe("Flags", func() { var A StructA var B StructB var flags types.GinkgoFlags - var bindings map[string]interface{} + var bindings map[string]any var sections types.GinkgoFlagSections var flagSet types.GinkgoFlagSet @@ -131,7 +131,7 @@ var _ = Describe("Flags", func() { StringSliceProperty: []string{"once", "upon", "a time"}, DeprecatedProperty: "n/a", } - bindings = map[string]interface{}{ + bindings = map[string]any{ "A": &A, "B": &B, } @@ -160,7 +160,7 @@ var _ = Describe("Flags", func() { DeprecatedProperty int32 //not supported } - bindings = map[string]interface{}{ + bindings = map[string]any{ "A": &A, "B": &UnsupportedStructB{}, } @@ -407,7 +407,7 @@ var _ = Describe("Flags", func() { var A StructA var B StructB var flags types.GinkgoFlags - var bindings map[string]interface{} + var bindings map[string]any BeforeEach(func() { A = StructA{ @@ -421,7 +421,7 @@ var _ = Describe("Flags", func() { StringSliceProperty: []string{"once", "upon", "a time"}, DeprecatedProperty: "n/a", } - bindings = map[string]interface{}{ + bindings = map[string]any{ "A": &A, "B": &B, } diff --git a/types/label_filter_test.go b/types/label_filter_test.go index cca3d2166..92aa8d357 100644 --- a/types/label_filter_test.go +++ b/types/label_filter_test.go @@ -54,7 +54,7 @@ var _ = Describe("LabelFilter", func() { } DescribeTable("Generating correct LabelFilter", - func(filter string, samples ...interface{}) { + func(filter string, samples ...any) { lf, err := types.ParseLabelFilter(filter) Ω(err).ShouldNot(HaveOccurred()) for _, sample := range samples { diff --git a/types/report_entry.go b/types/report_entry.go index 7b1524b52..63f7a9f6d 100644 --- a/types/report_entry.go +++ b/types/report_entry.go @@ -9,18 +9,18 @@ import ( // ReportEntryValue wraps a report entry's value ensuring it can be encoded and decoded safely into reports // and across the network connection when running in parallel type ReportEntryValue struct { - raw interface{} //unexported to prevent gob from freaking out about unregistered structs + raw any //unexported to prevent gob from freaking out about unregistered structs AsJSON string Representation string } -func WrapEntryValue(value interface{}) ReportEntryValue { +func WrapEntryValue(value any) ReportEntryValue { return ReportEntryValue{ raw: value, } } -func (rev ReportEntryValue) GetRawValue() interface{} { +func (rev ReportEntryValue) GetRawValue() any { return rev.raw } @@ -118,7 +118,7 @@ func (entry ReportEntry) StringRepresentation() string { // If used from a rehydrated JSON file _or_ in a ReportAfterSuite when running in parallel this will be // a JSON-decoded {}interface. If you want to reconstitute your original object you can decode the entry.Value.AsJSON // field yourself. -func (entry ReportEntry) GetRawValue() interface{} { +func (entry ReportEntry) GetRawValue() any { return entry.Value.GetRawValue() } From 98f27b46316c2b9bf73704bdf42d93d563180b71 Mon Sep 17 00:00:00 2001 From: Ehsan <77158825+ehsandavari@users.noreply.github.com> Date: Mon, 22 May 2023 14:09:28 +0330 Subject: [PATCH 2/2] Update test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index df4e3aefd..9058701b7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: steps: - uses: actions/setup-go@v4 with: - go-version: '1.19' + go-version: '1.20' - uses: actions/checkout@v3 - run: go mod tidy && git diff --exit-code go.mod go.sum build: