Skip to content

Commit

Permalink
WIP: debugging
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
  • Loading branch information
thaJeztah committed Jul 4, 2024
1 parent 4c62b2a commit 1c78142
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions e2e/cli-plugins/socket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cliplugins

import (
"bytes"
"context"
"errors"
"io"
"os/exec"
"strings"
Expand All @@ -11,6 +13,7 @@ import (

"github.com/creack/pty"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)

// TestPluginSocketBackwardsCompatible executes a plugin binary
Expand Down Expand Up @@ -190,13 +193,19 @@ 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()
// err := command.Run()
out, err := command.CombinedOutput()
t.Log(outB.String())
t.Log(string(out))
assert.ErrorContains(t, err, "exit status 2")
var exitError *exec.ExitError
if errors.As(err, &exitError) {
assert.Check(t, is.Equal(exitError.ExitCode(), 2))
}

// the plugin does not get signalled, but it does get it's
// context cancelled by the CLI through the socket
assert.Equal(t, outB.String(), "context cancelled\n")
assert.Check(t, is.Equal(strings.TrimSpace(outB.String()), context.Canceled.Error()))
})

t.Run("the main CLI exits after 3 signals", func(t *testing.T) {
Expand Down

0 comments on commit 1c78142

Please sign in to comment.