chore(parser): move Conf struct to meta.go

This commit is contained in:
张泊明518370910136 2025-02-11 03:41:17 -05:00
parent 61c9dcebb7
commit 49b7c7c5db
GPG Key ID: D47306D7062CDA9D
24 changed files with 140 additions and 140 deletions

View File

@ -4,6 +4,22 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "clangtidy"
type Match struct {
Keywords []string
Score int
}
type Conf struct {
Score int
RootDir string `default:"/w"`
Matches []Match
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
ForceQuitOnDeduct bool `default:"false"`
}
type ClangTidy struct{}
func init() {
stage.RegisterParser(name, &ClangTidy{})
}

View File

@ -6,22 +6,6 @@ import (
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Match struct {
Keywords []string
Score int
}
type Conf struct {
Score int
RootDir string `default:"/w"`
Matches []Match
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
ForceQuitOnDeduct bool `default:"false"`
}
type ClangTidy struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
stdout := executorResult.Files[conf.Stdout]
// stderr := executorResult.Files[conf.Stderr]

View File

@ -4,6 +4,21 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "cppcheck"
type Match struct {
Keywords []string
Score int
}
type Conf struct {
Score int
Matches []Match
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
ForceQuitOnDeduct bool `default:"false"`
}
type CppCheck struct{}
func init() {
stage.RegisterParser(name, &CppCheck{})
}

View File

@ -8,19 +8,6 @@ import (
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Match struct {
Keywords []string
Score int
}
type Conf struct {
Score int
Matches []Match
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
ForceQuitOnDeduct bool `default:"false"`
}
type Record struct {
File string `json:"file"`
Line int `json:"line"`
@ -30,8 +17,6 @@ type Record struct {
Id string `json:"id"`
}
type CppCheck struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
// stdout := executorResult.Files[conf.Stdout]
stderr := executorResult.Files[conf.Stderr]

View File

@ -4,6 +4,21 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "cpplint"
type Match struct {
Keywords []string
Score int
}
type Conf struct {
Score int
Matches []Match
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
ForceQuitOnDeduct bool `default:"false"`
}
type Cpplint struct{}
func init() {
stage.RegisterParser(name, &Cpplint{})
}

View File

@ -9,21 +9,6 @@ import (
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Match struct {
Keywords []string
Score int
}
type Conf struct {
Score int
Matches []Match
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
ForceQuitOnDeduct bool `default:"false"`
}
type Cpplint struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
stderr := executorResult.Files[conf.Stderr]
pattern := `(.+):(\d+): (.+) \[(.+)\] \[(\d)]\n`

View File

@ -4,6 +4,10 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "debug"
type Conf struct{}
type Debug struct{}
func init() {
stage.RegisterParser(name, &Debug{})
}

View File

@ -6,10 +6,6 @@ import (
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Conf struct{}
type Debug struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
slog.Debug("debug parser", "executorResult", executorResult)
for name, content := range executorResult.Files {

View File

@ -4,6 +4,26 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "diff"
type Conf struct {
PassComment string `default:"🥳Passed!\n"`
FailComment string `default:"🧐Failed...\n"`
FailOnNotAccepted bool `default:"true"`
ForceQuitOnFailed bool `default:"false"`
Cases []struct {
Outputs []struct {
Score int
FileName string
AnswerPath string
CompareSpace bool
AlwaysHide bool
ForceQuitOnDiff bool
MaxDiffLength int `default:"2048"` // just for reference
}
}
}
type Diff struct{}
func init() {
stage.RegisterParser(name, &Diff{})
}

View File

@ -19,26 +19,6 @@ const (
MOVE
)
type Conf struct {
PassComment string `default:"🥳Passed!\n"`
FailComment string `default:"🧐Failed...\n"`
FailOnNotAccepted bool `default:"true"`
ForceQuitOnFailed bool `default:"false"`
Cases []struct {
Outputs []struct {
Score int
FileName string
AnswerPath string
CompareSpace bool
AlwaysHide bool
ForceQuitOnDiff bool
MaxDiffLength int `default:"2048"` // just for reference
}
}
}
type Diff struct{}
func (*Diff) Run(results []stage.ExecutorResult, confAny any) (
[]stage.ParserResult, bool, error,
) {

View File

@ -4,6 +4,14 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "dummy"
type Conf struct {
Score int
Comment string
ForceQuit bool
}
type Dummy struct{}
func init() {
stage.RegisterParser(name, &Dummy{})
}

View File

@ -4,14 +4,6 @@ import (
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Conf struct {
Score int
Comment string
ForceQuit bool
}
type Dummy struct{}
func (*Dummy) Run(results []stage.ExecutorResult, confAny any) (
[]stage.ParserResult, bool, error,
) {

View File

@ -4,6 +4,13 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "healthcheck"
type Healthcheck struct{}
type Conf struct {
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
}
func init() {
stage.RegisterParser(name, &Healthcheck{})
}

View File

@ -10,13 +10,6 @@ import (
"github.com/joint-online-judge/JOJ3/pkg/healthcheck"
)
type Healthcheck struct{}
type Conf struct {
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
}
func Parse(executorResult stage.ExecutorResult, conf Conf) (stage.ParserResult, bool) {
stdout := executorResult.Files[conf.Stdout]
stderr := executorResult.Files[conf.Stderr]

View File

@ -4,6 +4,21 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "keyword"
type Match struct {
Keywords []string
Score int
MaxMatchCount int
}
type Conf struct {
Score int
Files []string
ForceQuitOnDeduct bool `default:"false"`
Matches []Match
}
type Keyword struct{}
func init() {
stage.RegisterParser(name, &Keyword{})
}

View File

@ -8,21 +8,6 @@ import (
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Match struct {
Keywords []string
Score int
MaxMatchCount int
}
type Conf struct {
Score int
Files []string
ForceQuitOnDeduct bool `default:"false"`
Matches []Match
}
type Keyword struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
score := conf.Score
comment := ""

View File

@ -4,6 +4,14 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "log"
type Conf struct {
FileName string `default:"stdout"`
Msg string `default:"log msg"`
Level int `default:"0"`
}
type Log struct{}
func init() {
stage.RegisterParser(name, &Log{})
}

View File

@ -9,14 +9,6 @@ import (
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Conf struct {
FileName string `default:"stdout"`
Msg string `default:"log msg"`
Level int `default:"0"`
}
type Log struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
content := executorResult.Files[conf.FileName]
var data map[string]any

View File

@ -4,6 +4,21 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "result-detail"
type Conf struct {
Score int
ShowExecutorStatus bool `default:"true"`
ShowExitStatus bool `default:"false"`
ShowError bool `default:"false"`
ShowTime bool `default:"true"`
ShowMemory bool `default:"true"`
ShowRunTime bool `default:"false"`
ShowFiles []string
FilesInCodeBlock bool `default:"true"`
MaxFileLength int `default:"65536"`
}
type ResultDetail struct{}
func init() {
stage.RegisterParser(name, &ResultDetail{})
}

View File

@ -6,21 +6,6 @@ import (
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Conf struct {
Score int
ShowExecutorStatus bool `default:"true"`
ShowExitStatus bool `default:"false"`
ShowError bool `default:"false"`
ShowTime bool `default:"true"`
ShowMemory bool `default:"true"`
ShowRunTime bool `default:"false"`
ShowFiles []string
FilesInCodeBlock bool `default:"true"`
MaxFileLength int `default:"65536"`
}
type ResultDetail struct{}
func (*ResultDetail) Run(results []stage.ExecutorResult, confAny any) (
[]stage.ParserResult, bool, error,
) {

View File

@ -4,6 +4,14 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "result-status"
type Conf struct {
Score int
Comment string
ForceQuitOnNotAccepted bool `default:"true"`
}
type ResultStatus struct{}
func init() {
stage.RegisterParser(name, &ResultStatus{})
}

View File

@ -7,14 +7,6 @@ import (
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Conf struct {
Score int
Comment string
ForceQuitOnNotAccepted bool `default:"true"`
}
type ResultStatus struct{}
func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) (
[]stage.ParserResult, bool, error,
) {

View File

@ -4,6 +4,15 @@ import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "sample"
type Conf struct {
Score int
Comment string
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
}
type Sample struct{}
func init() {
stage.RegisterParser(name, &Sample{})
}

View File

@ -8,15 +8,6 @@ import (
"github.com/joint-online-judge/JOJ3/pkg/sample"
)
type Conf struct {
Score int
Comment string
Stdout string `default:"stdout"`
Stderr string `default:"stderr"`
}
type Sample struct{}
func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
stdout := executorResult.Files[conf.Stdout]
// stderr := executorResult.Files[conf.Stderr]