Skip to content

Commit

Permalink
[checks] display check status to TAP output
Browse files Browse the repository at this point in the history
  • Loading branch information
Songmu committed Jan 17, 2019
1 parent d5a179c commit bb06a4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
4 changes: 4 additions & 0 deletions checks/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strings"
"sync"

"github.com/mackerelio/checkers"
"github.com/mackerelio/mackerel-agent/config"
cli "gopkg.in/urfave/cli.v1"
yaml "gopkg.in/yaml.v2"
Expand Down Expand Up @@ -56,6 +57,7 @@ type result struct {
Name string `yaml:"-"`
Memo string `yaml:"memo,omitempty"`
Cmd []string `yaml:"command,flow"`
Status string `yaml:"status"`
Stdout string `yaml:"stdout,omitempty"`
Stderr string `yaml:"stderr,omitempty"`
ExitCode int `yaml:"exitCode,omitempty"`
Expand Down Expand Up @@ -94,10 +96,12 @@ func (cpc *checkPluginChecker) check() *result {
if err != nil {
errMsg = err.Error()
}

return &result{
Name: cpc.name,
Memo: p.Memo,
Cmd: cmd,
Status: checkers.Status(exitCode).String(),
ExitCode: exitCode,
Stdout: strings.TrimSpace(stdout),
Stderr: strings.TrimSpace(stderr),
Expand Down
2 changes: 2 additions & 0 deletions checks/checker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestRunChecks(t *testing.T) {
te := &testChecker{&result{
Name: "hoge",
Cmd: []string{"perl", "-E", "say 'Hello'"},
Status: "OK",
Stdout: "Hello",
ExitCode: 0,
}}
Expand All @@ -28,6 +29,7 @@ func TestRunChecks(t *testing.T) {
ok 1 - hoge
---
command: [perl, -E, say 'Hello']
status: OK
stdout: Hello
...
`
Expand Down

0 comments on commit bb06a4a

Please sign in to comment.