m/p/cmd: use predicates in RunCommand
This generalizes RunCommand by making it accept any completion
predicate function.
Change-Id: Ic6b911244aaecd16c01000050fca618a8c8e09d7
Reviewed-on: https://review.monogon.dev/c/monogon/+/846
Reviewed-by: Sergiusz Bazanski <serge@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/cli/metroctl/test/test.go b/metropolis/cli/metroctl/test/test.go
index 41cd2b5..4f572a1 100644
--- a/metropolis/cli/metroctl/test/test.go
+++ b/metropolis/cli/metroctl/test/test.go
@@ -25,7 +25,8 @@
}
log.Printf("$ metroctl %s", strings.Join(args, " "))
- found, err := cmd.RunCommand(ctx, path, args, expect)
+ // Terminate metroctl as soon as the expected output is found.
+ found, err := cmd.RunCommand(ctx, path, args, cmd.TerminateIfFound(expect))
if err != nil {
return fmt.Errorf("while running metroctl: %v", err)
}