MCPcopy
hub / github.com/docker/compose / WaitForCmdResult

Method WaitForCmdResult

pkg/e2e/framework.go:434–453  ·  pkg/e2e/framework.go::CLI.WaitForCmdResult

WaitForCmdResult try to execute a cmd until resulting output matches given predicate

(
	t testing.TB,
	command icmd.Cmd,
	predicate func(*icmd.Result) bool,
	timeout time.Duration,
	delay time.Duration,
)

Source from the content-addressed store, hash-verified

432
433// WaitForCmdResult try to execute a cmd until resulting output matches given predicate
434func (c *CLI) WaitForCmdResult(
435 t testing.TB,
436 command icmd.Cmd,
437 predicate func(*icmd.Result) bool,
438 timeout time.Duration,
439 delay time.Duration,
440) {
441 t.Helper()
442 assert.Assert(t, timeout.Nanoseconds() > delay.Nanoseconds(), "timeout must be greater than delay")
443 var res *icmd.Result
444 checkStopped := func(logt poll.LogT) poll.Result {
445 fmt.Printf("\t[%s] %s\n", t.Name(), strings.Join(command.Command, " "))
446 res = icmd.RunCmd(command)
447 if !predicate(res) {
448 return poll.Continue("Cmd output did not match requirement: %q", res.Combined())
449 }
450 return poll.Success()
451 }
452 poll.WaitOn(t, checkStopped, poll.WithDelay(delay), poll.WithTimeout(timeout))
453}
454
455// WaitForCondition wait for predicate to execute to true
456func (c *CLI) WaitForCondition(

Callers 2

TestLocalComposeUpFunction · 0.95
TestRestartFunction · 0.80

Calls 2

RunCmdMethod · 0.80
NameMethod · 0.45

Tested by 2

TestLocalComposeUpFunction · 0.76
TestRestartFunction · 0.64