From 77bcfb91af5cd2d2e5730604847533b402c043f0 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Thu, 16 May 2024 14:25:36 +0000 Subject: [PATCH] backport of commit 6f299f5228ca4714a993d72500e02f87f90e148a --- packer_test/gadgets_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packer_test/gadgets_test.go b/packer_test/gadgets_test.go index 903cd3de5..3ddd29e55 100644 --- a/packer_test/gadgets_test.go +++ b/packer_test/gadgets_test.go @@ -158,3 +158,13 @@ func (c CustomCheck) Check(stdout, stderr string, err error) error { func (c CustomCheck) Name() string { return fmt.Sprintf("custom check - %s", c.name) } + +// LineCountCheck builds a pipe checker to count the number of lines on stdout by default +// +// To change the stream(s) on which to perform the check, you can call SetStream on the +// returned pipe checker. +func LineCountCheck(lines int) *PipeChecker { + return MkPipeCheck(fmt.Sprintf("line count (%d)", lines), LineCount()). + SetTester(IntCompare(eq, lines)). + SetStream(OnlyStdout) +}