feat(parser): make stdout & stderr file in conf

This commit is contained in:
张泊明518370910136 2024-10-29 17:02:35 -04:00
parent d56e3e5ebc
commit cda3faeb9a
GPG Key ID: D47306D7062CDA9D
4 changed files with 25 additions and 10 deletions

View File

@ -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)) {

View File

@ -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{

View File

@ -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
}

View File

@ -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,