Skip to content

Commit b728fdd

Browse files
committed
fix arg handling
1 parent 38bb3b1 commit b728fdd

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

runner/main.go

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ type ResultSet []Result
2929

3030
// Plugin defines a partial struct that captures plugin type
3131
type Plugin struct {
32-
Type string `json:"type"`
33-
json.RawMessage
32+
Type string `json:"type"`
33+
Args json.RawMessage `json:"args"`
3434
}
3535

3636
// Check defines a set of expected/actual plugins
@@ -84,7 +84,11 @@ func (p Plugin) Run() Value {
8484
if err != nil {
8585
return Value{Error: err}
8686
}
87-
stdin.Write(p.RawMessage)
87+
if len(p.Args) == 0 {
88+
stdin.Write([]byte("{}"))
89+
} else {
90+
stdin.Write(p.Args)
91+
}
8892
stdin.Close()
8993

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

100-
return Value{Output: stdoutBytes.String()}
104+
return Value{Output: strings.TrimSpace(stdoutBytes.String())}
101105
}
102106

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

0 commit comments

Comments
 (0)