feat: check result status in diff parser
All checks were successful
build-image / create-empty-commit (push) Successful in 6s
checks / build (push) Successful in 1m17s

This commit is contained in:
张泊明518370910136 2024-09-30 01:04:02 -04:00
parent c13b3465c1
commit dd8dc68eeb
GPG Key ID: D47306D7062CDA9D

View File

@ -8,6 +8,7 @@ import (
"unicode" "unicode"
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage" "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
"github.com/criyle/go-judge/envexec"
) )
// operation represents the type of edit operation. // operation represents the type of edit operation.
@ -21,7 +22,8 @@ const (
type Conf struct { type Conf struct {
Cases []struct { Cases []struct {
Outputs []struct { IgnoreResultStatus bool
Outputs []struct {
Score int Score int
FileName string FileName string
AnswerPath string AnswerPath string
@ -44,10 +46,18 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
} }
var res []stage.ParserResult var res []stage.ParserResult
forceQuit := false
for i, caseConf := range conf.Cases { for i, caseConf := range conf.Cases {
result := results[i] result := results[i]
score := 0 score := 0
comment := "" comment := ""
if !caseConf.IgnoreResultStatus &&
result.Status != stage.Status(envexec.StatusAccepted) {
forceQuit = true
comment += fmt.Sprintf(
"Unexpected executor status: %s.", result.Status,
)
}
for _, output := range caseConf.Outputs { for _, output := range caseConf.Outputs {
answer, err := os.ReadFile(output.AnswerPath) answer, err := os.ReadFile(output.AnswerPath)
if err != nil { if err != nil {
@ -83,7 +93,7 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
}) })
} }
return res, false, nil return res, forceQuit, nil
} }
// compareChars compares two strings character by character, optionally ignoring whitespace. // compareChars compares two strings character by character, optionally ignoring whitespace.