test: rename ExpectMatchContext to ExpectMatch (#25998)

Cleans the last few instances of ExpectMatch that didn't use the new `(ctx, ...)` variant, then deletes the deprecated method and renames `ExpectMatchContext` to drop the `Context` suffix.
This commit is contained in:
Spike Curtis
2026-06-03 15:30:37 -04:00
committed by GitHub
parent 7d7cc27581
commit 5b692bf1cc
66 changed files with 524 additions and 536 deletions
+2 -22
View File
@@ -145,31 +145,11 @@ func (e *Expecter) logClose(name string, c io.Closer) {
e.Logf("closed %s: %v", name, err)
}
// Deprecated: use ExpectMatchContext instead.
// This uses a background context, so will not respect the test's context.
func (e *Expecter) ExpectMatch(str string) string {
return e.expectMatchContextFunc(str, e.ExpectMatchContext)
}
func (e *Expecter) ExpectRegexMatch(str string) string {
return e.expectMatchContextFunc(str, e.ExpectRegexMatchContext)
}
func (e *Expecter) expectMatchContextFunc(str string, fn func(ctx context.Context, str string) string) string {
e.t.Helper()
timeout, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium)
defer cancel()
return fn(timeout, str)
}
// TODO(mafredri): Rename this to ExpectMatch when refactoring.
func (e *Expecter) ExpectMatchContext(ctx context.Context, str string) string {
func (e *Expecter) ExpectMatch(ctx context.Context, str string) string {
return e.expectMatcherFunc(ctx, str, strings.Contains)
}
func (e *Expecter) ExpectRegexMatchContext(ctx context.Context, str string) string {
func (e *Expecter) ExpectRegexMatch(ctx context.Context, str string) string {
return e.expectMatcherFunc(ctx, str, func(src, pattern string) bool {
return regexp.MustCompile(pattern).MatchString(src)
})