Skip to content

Crashed launched plugins are difficult to debug #162

@Benehiko

Description

@Benehiko

It would be nice to have a way to get the stdout and stderr of a launched plugin. At the moment we just have the exit code, which isn't very useful to debug with.

To get any sort of indication of what failed, we need to manually short circuit the test plugins in dummy.go.

func PluginCommand(t *testing.T, cfg PluginCfg) (*exec.Cmd, func() (*PluginResult, error)) {
	t.Helper()
	cfgStr, err := cfg.toString()
	assert.NoError(t, err)
	cmd := exec.Command(os.Args[0]) // run the test binary again
	var stdoutBuf, stderrBuf bytes.Buffer
-       cmd.Stdout = stdoutBuf
-       cmd.Stderr = stderrBuf
+       cmd.Stdout = os.Stdout
+       cmd.Stderr = os.Stdout
	cmd.Env = append(os.Environ(),
		"RUN_AS_DUMMY_PLUGIN=1",
		dummyPluginCfgEnv+"="+cfgStr,
	)

It would be best to get the output of the buffer returned to the caller so that the caller can log/comparison check the output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions