diff --git a/internal/parser/clangtidy/parser.go b/internal/parser/clangtidy/parser.go index 85ca466..35ae6f5 100644 --- a/internal/parser/clangtidy/parser.go +++ b/internal/parser/clangtidy/parser.go @@ -17,13 +17,15 @@ type Conf struct { Score int `default:"100"` RootDir string `default:"/w"` Matches []Match + Stdout string `default:"stdout"` + Stderr string `default:"stderr"` } type ClangTidy struct{} func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { - stdout := executorResult.Files["stdout"] - stderr := executorResult.Files["stderr"] + stdout := executorResult.Files[conf.Stdout] + stderr := executorResult.Files[conf.Stderr] if executorResult.Status != stage.Status(envexec.StatusAccepted) { if !((executorResult.Status == stage.Status(envexec.StatusNonzeroExitStatus)) && (executorResult.ExitStatus == 1)) { diff --git a/internal/parser/cppcheck/parser.go b/internal/parser/cppcheck/parser.go index 87b6f32..f6606ce 100644 --- a/internal/parser/cppcheck/parser.go +++ b/internal/parser/cppcheck/parser.go @@ -19,6 +19,8 @@ type Match struct { type Conf struct { Score int `default:"100"` Matches []Match + Stdout string `default:"stdout"` + Stderr string `default:"stderr"` } type Record struct { @@ -31,8 +33,8 @@ type Record struct { } func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { - // stdout := executorResult.Files["stdout"] - stderr := executorResult.Files["stderr"] + // stdout := executorResult.Files[conf.Stdout] + stderr := executorResult.Files[conf.Stderr] if executorResult.Status != stage.Status(envexec.StatusAccepted) { return stage.ParserResult{ diff --git a/internal/parser/healthcheck/parser.go b/internal/parser/healthcheck/parser.go index 0408695..a123294 100644 --- a/internal/parser/healthcheck/parser.go +++ b/internal/parser/healthcheck/parser.go @@ -9,9 +9,14 @@ import ( type Healthcheck struct{} -func Parse(executorResult stage.ExecutorResult) (stage.ParserResult, bool) { - stdout := executorResult.Files["stdout"] - stderr := executorResult.Files["stderr"] +type Conf struct { + Stdout string `default:"stdout"` + Stderr string `default:"stderr"` +} + +func Parse(executorResult stage.ExecutorResult, conf Conf) (stage.ParserResult, bool) { + stdout := executorResult.Files[conf.Stdout] + stderr := executorResult.Files[conf.Stderr] if executorResult.Status != stage.Status(envexec.StatusAccepted) { return stage.ParserResult{ Score: 0, @@ -30,10 +35,14 @@ func Parse(executorResult stage.ExecutorResult) (stage.ParserResult, bool) { func (*Healthcheck) Run(results []stage.ExecutorResult, confAny any) ( []stage.ParserResult, bool, error, ) { + conf, err := stage.DecodeConf[Conf](confAny) + if err != nil { + return nil, true, err + } var res []stage.ParserResult forceQuit := false for _, result := range results { - parserResult, forceQuitResult := Parse(result) + parserResult, forceQuitResult := Parse(result, *conf) res = append(res, parserResult) forceQuit = forceQuit || forceQuitResult } diff --git a/internal/parser/sample/parser.go b/internal/parser/sample/parser.go index 2e670c0..2eabf24 100644 --- a/internal/parser/sample/parser.go +++ b/internal/parser/sample/parser.go @@ -12,13 +12,15 @@ import ( type Conf struct { Score int Comment string + Stdout string `default:"stdout"` + Stderr string `default:"stderr"` } type Sample struct{} func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { - stdout := executorResult.Files["stdout"] - stderr := executorResult.Files["stderr"] + stdout := executorResult.Files[conf.Stdout] + stderr := executorResult.Files[conf.Stderr] if executorResult.Status != stage.Status(envexec.StatusAccepted) { return stage.ParserResult{ Score: 0,