Compare commits

...

2 Commits

Author SHA1 Message Date
c218c93069
feat(parser/diff): option to force quit on diff
All checks were successful
build / build (push) Successful in 1m7s
build / trigger-build-image (push) Successful in 8s
2024-10-15 03:43:19 -04:00
a001b26b66
feat(parser/diff): remove result status check 2024-10-15 03:42:16 -04:00

View File

@ -7,7 +7,6 @@ import (
"strings" "strings"
"unicode" "unicode"
"github.com/criyle/go-judge/envexec"
"github.com/joint-online-judge/JOJ3/internal/stage" "github.com/joint-online-judge/JOJ3/internal/stage"
) )
@ -24,13 +23,13 @@ type Conf struct {
PassComment string `default:"🥳Passed!\n"` PassComment string `default:"🥳Passed!\n"`
FailComment string `default:"🧐Failed...\n"` FailComment string `default:"🧐Failed...\n"`
Cases []struct { Cases []struct {
IgnoreResultStatus bool
Outputs []struct { Outputs []struct {
Score int Score int
FileName string FileName string
AnswerPath string AnswerPath string
CompareSpace bool CompareSpace bool
AlwaysHide bool AlwaysHide bool
ForceQuitOnDiff bool
} }
} }
} }
@ -54,13 +53,6 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
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,
)
} else {
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 {
@ -76,6 +68,9 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
score += output.Score score += output.Score
comment += conf.PassComment comment += conf.PassComment
} else { } else {
if output.ForceQuitOnDiff {
forceQuit = true
}
comment += conf.FailComment comment += conf.FailComment
comment += fmt.Sprintf("Difference found in `%s`.\n", comment += fmt.Sprintf("Difference found in `%s`.\n",
output.FileName) output.FileName)
@ -101,7 +96,6 @@ func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
} }
} }
} }
}
res = append(res, stage.ParserResult{ res = append(res, stage.ParserResult{
Score: score, Score: score,
Comment: comment, Comment: comment,