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.