feat: check result status in diff parser
This commit is contained in:
parent
c13b3465c1
commit
dd8dc68eeb
|
@ -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,6 +22,7 @@ const (
|
||||||
|
|
||||||
type Conf struct {
|
type Conf struct {
|
||||||
Cases []struct {
|
Cases []struct {
|
||||||
|
IgnoreResultStatus bool
|
||||||
Outputs []struct {
|
Outputs []struct {
|
||||||
Score int
|
Score int
|
||||||
FileName string
|
FileName 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.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user