Skip to content

Commit 4d157d7

Browse files
committed
WIP: debugging
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 4c62b2a commit 4d157d7

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

e2e/cli-plugins/socket_test.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
package cliplugins
22

33
import (
4-
"bytes"
4+
"context"
5+
"errors"
56
"io"
67
"os/exec"
78
"strings"
@@ -11,6 +12,7 @@ import (
1112

1213
"github.com/creack/pty"
1314
"gotest.tools/v3/assert"
15+
is "gotest.tools/v3/assert/cmp"
1416
)
1517

1618
// TestPluginSocketBackwardsCompatible executes a plugin binary
@@ -177,9 +179,9 @@ func TestPluginSocketCommunication(t *testing.T) {
177179
t.Run("the plugin does not get signalled", func(t *testing.T) {
178180
cmd := run("presocket", "test-socket")
179181
command := exec.Command(cmd.Command[0], cmd.Command[1:]...)
180-
outB := bytes.Buffer{}
181-
command.Stdout = &outB
182-
command.Stderr = &outB
182+
// outB := bytes.Buffer{}
183+
// command.Stdout = &outB
184+
// command.Stderr = &outB
183185
command.SysProcAttr = &syscall.SysProcAttr{
184186
Setpgid: true,
185187
}
@@ -190,13 +192,19 @@ func TestPluginSocketCommunication(t *testing.T) {
190192
err := syscall.Kill(command.Process.Pid, syscall.SIGINT)
191193
assert.NilError(t, err, "failed to signal CLI process")
192194
}()
193-
err := command.Run()
194-
t.Log(outB.String())
195+
// err := command.Run()
196+
out, err := command.CombinedOutput()
197+
// t.Log(outB.String())
198+
t.Log(string(out))
195199
assert.ErrorContains(t, err, "exit status 2")
200+
var exitError *exec.ExitError
201+
if errors.As(err, &exitError) {
202+
assert.Check(t, is.Equal(exitError.ExitCode(), 2))
203+
}
196204

197205
// the plugin does not get signalled, but it does get it's
198206
// context cancelled by the CLI through the socket
199-
assert.Equal(t, outB.String(), "context cancelled\n")
207+
assert.Check(t, is.Equal(strings.TrimSpace(string(out)), context.Canceled.Error()))
200208
})
201209

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

0 commit comments

Comments
 (0)