From baf35da40104175a837a7001285abf1e05711c9b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 4 Jul 2024 17:42:09 +0200 Subject: [PATCH] e2e/cli-plugins: use cmd.CombinedOutput() instead of custom buffer Also remove a debug-log, as the output would already be shown if the test would fail. Signed-off-by: Sebastiaan van Stijn --- e2e/cli-plugins/socket_test.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/e2e/cli-plugins/socket_test.go b/e2e/cli-plugins/socket_test.go index 4c2539b73e..8d80824d5c 100644 --- a/e2e/cli-plugins/socket_test.go +++ b/e2e/cli-plugins/socket_test.go @@ -1,7 +1,6 @@ package cliplugins import ( - "bytes" "io" "os/exec" "strings" @@ -178,9 +177,6 @@ func TestPluginSocketCommunication(t *testing.T) { t.Run("the plugin does not get signalled", func(t *testing.T) { cmd := run("presocket", "test-socket") command := exec.Command(cmd.Command[0], cmd.Command[1:]...) - outB := bytes.Buffer{} - command.Stdout = &outB - command.Stderr = &outB command.SysProcAttr = &syscall.SysProcAttr{ Setpgid: true, } @@ -191,14 +187,13 @@ func TestPluginSocketCommunication(t *testing.T) { err := syscall.Kill(command.Process.Pid, syscall.SIGINT) assert.NilError(t, err, "failed to signal CLI process") }() - err := command.Run() - t.Log(outB.String()) + out, err := command.CombinedOutput() assert.ErrorContains(t, err, "exit status 2") // the plugin does not get signalled, but it does get its // context canceled by the CLI through the socket const expected = "test-socket: exiting after context was done" - actual := strings.TrimSpace(outB.String()) + actual := strings.TrimSpace(string(out)) assert.Check(t, is.Equal(actual, expected)) })