feat(parser/diff): log parser summary
All checks were successful
submodules sync / sync (push) Successful in 48s
build / build (push) Successful in 1m43s
build / trigger-build-image (push) Successful in 7s

This commit is contained in:
张泊明518370910136 2024-11-12 21:24:43 -05:00
parent ea75e992aa
commit c2818bb348
GPG Key ID: D47306D7062CDA9D

View File

@ -7,6 +7,7 @@ import (
"strings"
"unicode"
"github.com/criyle/go-judge/envexec"
"github.com/joint-online-judge/JOJ3/internal/stage"
)
@ -35,6 +36,13 @@ type Conf struct {
}
}
type DiffParserSummary struct {
Status stage.Status
Time uint64
Memory uint64
RunTime uint64
}
type Diff struct{}
func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
@ -50,10 +58,19 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
var res []stage.ParserResult
forceQuit := false
var summary DiffParserSummary
summary.Status = stage.Status(envexec.StatusAccepted)
for i, caseConf := range conf.Cases {
result := results[i]
score := 0
comment := ""
if result.Status != stage.Status(envexec.StatusAccepted) &&
summary.Status == stage.Status(envexec.StatusAccepted) {
summary.Status = result.Status
}
summary.Time += result.Time
summary.Memory += result.Memory
summary.RunTime += result.RunTime
for _, output := range caseConf.Outputs {
answer, err := os.ReadFile(output.AnswerPath)
if err != nil {
@ -104,6 +121,7 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
Comment: comment,
})
}
slog.Info("diff parser run done", "diffParserSummary", summary)
return res, forceQuit, nil
}