Skip to content

Commit

Permalink
e2e: continuously print output in upgrade test
Browse files Browse the repository at this point in the history
  • Loading branch information
msanft committed Dec 14, 2023
1 parent a0041c1 commit 62f1251
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions e2e/internal/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ SPDX-License-Identifier: AGPL-3.0-only
package upgrade

import (
"bufio"
"context"
"errors"
"flag"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 62f1251

Please sign in to comment.