From 62f12514f54b0b7088ceaa0c4eda41d6c235ba53 Mon Sep 17 00:00:00 2001 From: Moritz Sanft <58110325+msanft@users.noreply.github.com> Date: Thu, 14 Dec 2023 12:52:26 +0100 Subject: [PATCH] e2e: continuously print output in upgrade test --- e2e/internal/upgrade/upgrade_test.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/e2e/internal/upgrade/upgrade_test.go b/e2e/internal/upgrade/upgrade_test.go index caf6a90a9f..7e8e7fe5b8 100644 --- a/e2e/internal/upgrade/upgrade_test.go +++ b/e2e/internal/upgrade/upgrade_test.go @@ -9,6 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only package upgrade import ( + "bufio" "context" "errors" "flag" @@ -471,17 +472,15 @@ func runCommandWithSeparateOutputs(cmd *exec.Cmd) (stdout, stderr []byte, err er return } - stdout, err = io.ReadAll(stdoutIn) - if err != nil { - err = fmt.Errorf("start command: %w", err) - return + continuouslyPrintOutput := func(r io.Reader, prefix string) { + scanner := bufio.NewScanner(r) + for scanner.Scan() { + fmt.Printf("%s: %s\n", prefix, scanner.Text()) + } } - stderr, err = io.ReadAll(stderrIn) - if err != nil { - err = fmt.Errorf("start command: %w", err) - return - } + go continuouslyPrintOutput(stdoutIn, "stdout") + go continuouslyPrintOutput(stderrIn, "stderr") if err = cmd.Wait(); err != nil { err = fmt.Errorf("wait for command to finish: %w", err)