refactor(parser/elf): modern structure
This commit is contained in:
parent
b57e3f81ca
commit
a4232884c5
|
@ -4,6 +4,13 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
|
||||||
|
|
||||||
var name = "elf"
|
var name = "elf"
|
||||||
|
|
||||||
|
type Conf struct {
|
||||||
|
Score int
|
||||||
|
Comment string
|
||||||
|
}
|
||||||
|
|
||||||
|
type Elf struct{}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
stage.RegisterParser(name, &Elf{})
|
stage.RegisterParser(name, &Elf{})
|
||||||
}
|
}
|
|
@ -5,22 +5,14 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log/slog"
|
"log/slog"
|
||||||
|
|
||||||
"github.com/criyle/go-judge/envexec"
|
|
||||||
"github.com/joint-online-judge/JOJ3/internal/stage"
|
"github.com/joint-online-judge/JOJ3/internal/stage"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Conf struct {
|
|
||||||
Score int
|
|
||||||
Comment string
|
|
||||||
}
|
|
||||||
|
|
||||||
type Elf struct{}
|
|
||||||
|
|
||||||
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
|
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
|
||||||
stdout := executorResult.Files["stdout"]
|
stdout := executorResult.Files["stdout"]
|
||||||
stderr := executorResult.Files["stderr"]
|
stderr := executorResult.Files["stderr"]
|
||||||
if executorResult.Status != stage.Status(envexec.StatusAccepted) {
|
if executorResult.Status != stage.StatusAccepted {
|
||||||
return stage.ParserResult{
|
return stage.ParserResult{
|
||||||
Score: 0,
|
Score: 0,
|
||||||
Comment: fmt.Sprintf(
|
Comment: fmt.Sprintf(
|
||||||
|
@ -88,7 +80,7 @@ func (*Elf) Run(results []stage.ExecutorResult, confAny any) (
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, true, err
|
return nil, true, err
|
||||||
}
|
}
|
||||||
var res []stage.ParserResult
|
res := make([]stage.ParserResult, 0, len(results))
|
||||||
for _, result := range results {
|
for _, result := range results {
|
||||||
res = append(res, Parse(result, *conf))
|
res = append(res, Parse(result, *conf))
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user