Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Fix #1230: Return execute errors if plugin never starts #1279

Merged
merged 1 commit into from
Oct 12, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions control/plugin/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type ExecutablePlugin struct {
// An interface for the interactions ExecutablePlugin has with an exec.Cmd
// This way, the underlying Cmd can be mocked.
type command interface {
Start()
Start() error
Kill() error
Path() string
}
Expand Down Expand Up @@ -73,7 +73,7 @@ func (cw *commandWrapper) Kill() error {
_, err := cw.cmd.Process.Wait()
return err
}
func (cw *commandWrapper) Start() { cw.cmd.Start() }
func (cw *commandWrapper) Start() error { return cw.cmd.Start() }

// Initialize a new ExecutablePlugin from path to executable and daemon mode (true or false)
func NewExecutablePlugin(a Arg, path string) (*ExecutablePlugin, error) {
Expand Down Expand Up @@ -112,7 +112,10 @@ func (e *ExecutablePlugin) Run(timeout time.Duration) (Response, error) {
stdOutScanner := bufio.NewScanner(e.stdout)

// Start the command and begin reading its output.
e.cmd.Start()
if err = e.cmd.Start(); err != nil {
return resp, err
}

e.captureStderr()
go func() {
for stdOutScanner.Scan() {
Expand Down
2 changes: 1 addition & 1 deletion control/plugin/execution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type mockCmd struct{}

func (mc *mockCmd) Path() string { return "" }
func (mc *mockCmd) Kill() error { return nil }
func (mc *mockCmd) Start() {}
func (mc *mockCmd) Start() error { return nil }

func setupMockExec(resp []byte, timeout bool) *ExecutablePlugin {
stdout, stdoutw := io.Pipe()
Expand Down