Skip to content

Commit

Permalink
fix arg handling
Browse files Browse the repository at this point in the history
  • Loading branch information
akerl committed Jan 20, 2023
1 parent 38bb3b1 commit b728fdd
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions runner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ type ResultSet []Result

// Plugin defines a partial struct that captures plugin type
type Plugin struct {
Type string `json:"type"`
json.RawMessage
Type string `json:"type"`
Args json.RawMessage `json:"args"`
}

// Check defines a set of expected/actual plugins
Expand Down Expand Up @@ -84,7 +84,11 @@ func (p Plugin) Run() Value {
if err != nil {
return Value{Error: err}
}
stdin.Write(p.RawMessage)
if len(p.Args) == 0 {
stdin.Write([]byte("{}"))
} else {
stdin.Write(p.Args)
}
stdin.Close()

var stdoutBytes bytes.Buffer
Expand All @@ -94,10 +98,10 @@ func (p Plugin) Run() Value {
cmd.Stderr = &stderrBytes
err = cmd.Run()
if err != nil {
return Value{Error: fmt.Errorf("%s: %s", err, stderrBytes.String())}
return Value{Error: fmt.Errorf("%s: %s", err, strings.TrimSpace(stderrBytes.String()))}
}

return Value{Output: stdoutBytes.String()}
return Value{Output: strings.TrimSpace(stdoutBytes.String())}
}

// Matches checks if a result ran successfully and if its expected and actual values match
Expand Down

0 comments on commit b728fdd

Please sign in to comment.