You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CHANGELOG.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -322,7 +322,7 @@ Require Go 1.22+
322
322
323
323
### Features
324
324
325
-
Introducting[gcustom](https://onsi.github.io/gomega/#gcustom-a-convenient-mechanism-for-buildling-custom-matchers) - a convenient mechanism for building custom matchers.
325
+
Introducing[gcustom](https://onsi.github.io/gomega/#gcustom-a-convenient-mechanism-for-buildling-custom-matchers) - a convenient mechanism for building custom matchers.
326
326
327
327
This is an RC release for `gcustom`. The external API may be tweaked in response to feedback however it is expected to remain mostly stable.
328
328
@@ -461,7 +461,7 @@ These improvements are all documented in [Gomega's docs](https://onsi.github.io/
461
461
- Fix max number of samples in experiments on non-64-bit systems. (#528) [1c84497]
462
462
- Remove dependency on ginkgo v1.16.4 (#530) [4dea8d5]
463
463
- Fix for Go 1.18 (#532) [56d2a29]
464
-
- Document precendence of timeouts (#533) [b607941]
464
+
- Document precedence of timeouts (#533) [b607941]
465
465
466
466
## 1.18.1
467
467
@@ -478,7 +478,7 @@ These improvements are all documented in [Gomega's docs](https://onsi.github.io/
478
478
## Fixes
479
479
- Gomega now uses ioutil for Go 1.15 and lower (#492) - official support is only for the most recent two major versions of Go but this will unblock users who need to stay on older unsupported versions of Go. [c29c1c0]
480
480
481
-
## Maintenace
481
+
## Maintenance
482
482
- Remove Travis workflow (#491) [72e6040]
483
483
- Upgrade to Ginkgo 2.0.0 GA [f383637]
484
484
- chore: fix description of HaveField matcher (#487) [2b4b2c0]
@@ -726,7 +726,7 @@ Improvements:
726
726
727
727
- Added `BeSent` which attempts to send a value down a channel and fails if the attempt blocks. Can be paired with `Eventually` to safely send a value down a channel with a timeout.
728
728
-`Ω`, `Expect`, `Eventually`, and `Consistently` now immediately `panic` if there is no registered fail handler. This is always a mistake that can hide failing tests.
729
-
-`Receive()` no longer errors when passed a closed channel, it's perfectly fine to attempt to read from a closed channel so Ω(c).Should(Receive()) always fails and Ω(c).ShoudlNot(Receive()) always passes with a closed channel.
729
+
-`Receive()` no longer errors when passed a closed channel, it's perfectly fine to attempt to read from a closed channel so Ω(c).Should(Receive()) always fails and Ω(c).ShouldNot(Receive()) always passes with a closed channel.
730
730
- Added `HavePrefix` and `HaveSuffix` matchers.
731
731
-`ghttp` can now handle concurrent requests.
732
732
- Added `Succeed` which allows one to write `Ω(MyFunction()).Should(Succeed())`.
@@ -736,7 +736,7 @@ Improvements:
736
736
-`ghttp` servers can take an `io.Writer`. `ghttp` will write a line to the writer when each request arrives.
737
737
- Added `WithTransform` matcher to allow munging input data before feeding into the relevant matcher
738
738
- Added boolean `And`, `Or`, and `Not` matchers to allow creating composite matchers
739
-
- Added `gbytes.TimeoutCloser`, `gbytes.TimeoutReader`, and `gbytes.TimeoutWriter` - these are convenience wrappers that timeout if the underlying Closer/Reader/Writer does not return within the alloted time.
739
+
- Added `gbytes.TimeoutCloser`, `gbytes.TimeoutReader`, and `gbytes.TimeoutWriter` - these are convenience wrappers that timeout if the underlying Closer/Reader/Writer does not return within the allotted time.
740
740
- Added `gbytes.BufferReader` - this constructs a `gbytes.Buffer` that asynchronously reads the passed-in `io.Reader` into its buffer.
741
741
742
742
Bug Fixes:
@@ -781,7 +781,7 @@ New Matchers:
781
781
782
782
Updated Matchers:
783
783
784
-
-`Receive` matcher can take a matcher as an argument and passes only if the channel under test receives an objet that satisfies the passed-in matcher.
784
+
-`Receive` matcher can take a matcher as an argument and passes only if the channel under test receives an object that satisfies the passed-in matcher.
785
785
- Matchers that implement `MatchMayChangeInTheFuture(actual interface{}) bool` can inform `Eventually` and/or `Consistently` when a match has no chance of changing status in the future. For example, `Receive` returns `false` when a channel is closed.
WithPrecompiledTemplate returns a CustomGomegaMatcher configured to use the passed-in template. The template should be precompiled with gcustom.ParseTemplate().
193
193
194
-
As with WithTemplate() you can provide a single pice of additional data as an optional argument. This is accessed in the template via {{.Data}}
194
+
As with WithTemplate() you can provide a single piece of additional data as an optional argument. This is accessed in the template via {{.Data}}
Load fetches an experiment from the cache. Lookup occurs by name. Load requires that the version numer in the cache is equal to or greater than the passed-in version.
109
+
Load fetches an experiment from the cache. Lookup occurs by name. Load requires that the version number in the cache is equal to or greater than the passed-in version.
110
110
111
111
If an experiment with corresponding name and version >= the passed-in version is found, it is unmarshaled and returned.
112
112
113
113
If no experiment is found, or the cached version is smaller than the passed-in version, Load will return nil.
114
114
115
115
When paired with Ginkgo you can cache experiments and prevent potentially expensive recomputation with this pattern:
116
116
117
-
const EXPERIMENT_VERSION = 1 //bump this to bust the cache and recompute _all_ experiments
Copy file name to clipboardexpand all lines: gmeasure/experiment.go
+19-19
Original file line number
Diff line number
Diff line change
@@ -22,9 +22,9 @@ Once measurements are complete, an Experiment can generate a comprehensive repor
22
22
23
23
Users can also access and analyze the resulting Measurements directly. Use Experiment.Get(NAME) to fetch the Measurement named NAME. This returned struct will have fields containing
24
24
all the data points and annotations recorded by the experiment. You can subsequently fetch the Measurement.Stats() to get a Stats struct that contains basic statistical information about the
25
-
Measurement (min, max, median, mean, standard deviation). You can order these Stats objects using RankStats() to identify best/worst performers across multpile experiments or measurements.
25
+
Measurement (min, max, median, mean, standard deviation). You can order these Stats objects using RankStats() to identify best/worst performers across multiple experiments or measurements.
26
26
27
-
gmeasure also supports caching Experiments via an ExperimentCache. The cache supports storing and retreiving experiments by name and version. This allows you to rerun code without
27
+
gmeasure also supports caching Experiments via an ExperimentCache. The cache supports storing and retrieving experiments by name and version. This allows you to rerun code without
28
28
repeating expensive experiments that may not have changed (which can be controlled by the cache version number). It also enables you to compare new experiment runs with older runs to detect
29
29
variations in performance/behavior.
30
30
@@ -66,8 +66,8 @@ type SamplingConfig struct {
66
66
67
67
// The Units decorator allows you to specify units (an arbitrary string) when recording values. It is ignored when recording durations.
// Units are only set the first time a value of a given name is recorded. In the example above any subsequent calls to e.RecordValue("length", X) will maintain the "inches" units even if a new set of Units("UNIT") are passed in later.
@@ -308,7 +308,7 @@ The resulting durations are recorded on a Duration Measurement with the passed-i
308
308
309
309
The callback is given a zero-based index that increments by one between samples. The callback must return an Annotation - this annotation is attached to the measured duration.
310
310
311
-
The Sampling is configured via the passed-in SamplingConfig
311
+
# The Sampling is configured via the passed-in SamplingConfig
312
312
313
313
SampleAnnotatedDuration supports the Style() and Precision() decorations.
314
314
*/
@@ -395,7 +395,7 @@ SampleAnnotatedValue samples the passed-in callback and records the return value
395
395
396
396
The callback is given a zero-based index that increments by one between samples. The callback must return a float64 and an Annotation - the annotation is attached to the recorded value.
397
397
398
-
The Sampling is configured via the passed-in SamplingConfig
398
+
# The Sampling is configured via the passed-in SamplingConfig
399
399
400
400
SampleValue supports the Style(), Units(), and Precision() decorations.
Ranking ranks a set of Stats by a specified RankingCritera. Use RankStats to create a Ranking.
37
+
Ranking ranks a set of Stats by a specified RankingCriteria. Use RankStats to create a Ranking.
38
38
39
39
When using Ginkgo, you can register Rankings as Report Entries via AddReportEntry. This will emit a formatted table representing the Stats in rank-order when Ginkgo generates the report.
Either way the context pasesd to Eventually is also passed to the underlying function. Now, when Ginkgo cancels the context both the FetchCount client and Gomega will be informed and can exit.
322
+
Either way the context passed to Eventually is also passed to the underlying function. Now, when Ginkgo cancels the context both the FetchCount client and Gomega will be informed and can exit.
323
323
324
324
By default, when a context is passed to Eventually *without* an explicit timeout, Gomega will rely solely on the context's cancellation to determine when to stop polling. If you want to specify a timeout in addition to the context you can do so using the .WithTimeout() method. For example:
now either the context cacnellation or the timeout will cause Eventually to stop polling.
328
+
now either the context cancellation or the timeout will cause Eventually to stop polling.
329
329
330
330
If, instead, you would like to opt out of this behavior and have Gomega's default timeouts govern Eventuallys that take a context you can call:
331
331
332
332
EnforceDefaultTimeoutsWhenUsingContexts()
333
333
334
-
in the DSL (or on a Gomega instance). Now all calls to Eventually that take a context will fail if eitehr the context is cancelled or the default timeout elapses.
334
+
in the DSL (or on a Gomega instance). Now all calls to Eventually that take a context will fail if either the context is cancelled or the default timeout elapses.
335
335
336
336
**Category 3: Making assertions _in_ the function passed into Eventually**
StopTrying can be used to signal to Eventually and Consistentlythat they should abort and stop trying. This always results in a failure of the assertion - and the failure message is the content of the StopTrying signal.
444
+
StopTrying can be used to signal to Eventually and Consistently that they should abort and stop trying. This always results in a failure of the assertion - and the failure message is the content of the StopTrying signal.
445
445
446
446
You can send the StopTrying signal by either returning StopTrying("message") as an error from your passed-in function _or_ by calling StopTrying("message").Now() to trigger a panic and end execution.
returnfmt.Errorf(`The function passed to %s has signature %s takes %d arguments but %d %s been provided. Please use %s().WithArguments() to pass the corect set of arguments.
227
+
returnfmt.Errorf(`The function passed to %s has signature %s takes %d arguments but %d %s been provided. Please use %s().WithArguments() to pass the correct set of arguments.
228
228
229
229
You can learn more at https://onsi.github.io/gomega/#eventually
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(int) string takes 1 arguments but 0 have been provided. Please use Eventually().WithArguments() to pass the corect set of arguments."))
1085
+
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(int) string takes 1 arguments but 0 have been provided. Please use Eventually().WithArguments() to pass the correct set of arguments."))
1086
1086
1087
1087
ig.G.Eventually(func(aint, bint) string {
1088
1088
return""
1089
1089
}).WithArguments(1).Should(Equal("foo"))
1090
-
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(int, int) string takes 2 arguments but 1 has been provided. Please use Eventually().WithArguments() to pass the corect set of arguments."))
1090
+
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(int, int) string takes 2 arguments but 1 has been provided. Please use Eventually().WithArguments() to pass the correct set of arguments."))
1091
1091
1092
1092
ig.G.Eventually(func(aint, bint) string {
1093
1093
return""
1094
1094
}).WithArguments(1, 2, 3).Should(Equal("foo"))
1095
-
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(int, int) string takes 2 arguments but 3 have been provided. Please use Eventually().WithArguments() to pass the corect set of arguments."))
1095
+
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(int, int) string takes 2 arguments but 3 have been provided. Please use Eventually().WithArguments() to pass the correct set of arguments."))
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(types.Gomega, int, int) string takes 3 arguments but 4 have been provided. Please use Eventually().WithArguments() to pass the corect set of arguments."))
1100
+
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(types.Gomega, int, int) string takes 3 arguments but 4 have been provided. Please use Eventually().WithArguments() to pass the correct set of arguments."))
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(int, int, ...int) string takes 3 arguments but 1 has been provided. Please use Eventually().WithArguments() to pass the corect set of arguments."))
1105
+
Ω(ig.FailureMessage).Should(ContainSubstring("The function passed to Eventually has signature func(int, int, ...int) string takes 3 arguments but 1 has been provided. Please use Eventually().WithArguments() to pass the correct set of arguments."))
// the first argument is a context, we should accept it as the context _only if_ it is **not** the only argumnent **and** the second argument is not a parseable duration
81
+
// the first argument is a context, we should accept it as the context _only if_ it is **not** the only argument **and** the second argument is not a parseable duration
82
82
// this is due to an unfortunate ambiguity in early version of Gomega in which multi-type durations are allowed after the actual
// Finally, if you want to match the received object as well as get the actual received value into a variable, so you can reason further about the value received,
205
-
// you can pass a pointer to a variable of the approriate type first, and second a matcher:
205
+
// you can pass a pointer to a variable of the appropriate type first, and second a matcher:
// HaveExactElements succeeds if actual contains elements that precisely match the elemets passed into the matcher. The ordering of the elements does matter.
398
+
// HaveExactElements succeeds if actual contains elements that precisely match the elements passed into the matcher. The ordering of the elements does matter.
399
399
// By default HaveExactElements() uses Equal() to match the elements, however custom matchers can be passed in instead. Here are some examples: