-
Notifications
You must be signed in to change notification settings - Fork 899
feat(cli): show queue position during workspace builds #12606
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
eb33f76
686c2b7
993904c
4df8a3b
b08e633
4367e65
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,7 @@ import ( | |
"context" | ||
"fmt" | ||
"io" | ||
"regexp" | ||
"runtime" | ||
"strings" | ||
"sync" | ||
|
@@ -145,16 +146,36 @@ type outExpecter struct { | |
} | ||
|
||
func (e *outExpecter) ExpectMatch(str string) string { | ||
return e.expectMatchContextFunc(str, e.ExpectMatchContext) | ||
} | ||
|
||
func (e *outExpecter) ExpectRegexMatch(str string) string { | ||
return e.expectMatchContextFunc(str, e.ExpectRegexMatchContext) | ||
} | ||
|
||
func (e *outExpecter) 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 e.ExpectMatchContext(timeout, str) | ||
return fn(timeout, str) | ||
} | ||
|
||
// TODO(mafredri): Rename this to ExpectMatch when refactoring. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mafredri not really sure what this TODO is about since both this and the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Essentially the non-context variant should be marked deprecated. All usage switched to context. Then delete the non-context one and rename this to not have context in the name. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK, is it because we need to be able to control the deadline? |
||
func (e *outExpecter) ExpectMatchContext(ctx context.Context, str string) string { | ||
return e.expectMatcherFunc(ctx, str, func(src, pattern string) bool { | ||
return strings.Contains(src, pattern) | ||
}) | ||
} | ||
|
||
func (e *outExpecter) ExpectRegexMatchContext(ctx context.Context, str string) string { | ||
return e.expectMatcherFunc(ctx, str, func(src, pattern string) bool { | ||
return regexp.MustCompile(pattern).MatchString(src) | ||
}) | ||
} | ||
|
||
func (e *outExpecter) expectMatcherFunc(ctx context.Context, str string, fn func(src, pattern string) bool) string { | ||
e.t.Helper() | ||
|
||
var buffer bytes.Buffer | ||
|
@@ -168,7 +189,7 @@ func (e *outExpecter) ExpectMatchContext(ctx context.Context, str string) string | |
if err != nil { | ||
return err | ||
} | ||
if strings.Contains(buffer.String(), str) { | ||
if fn(buffer.String(), str) { | ||
return nil | ||
} | ||
} | ||
|
Uh oh!
There was an error while loading. Please reload this page.