feat(parser/debug): debug parser

This commit is contained in:
张泊明518370910136 2025-01-31 22:07:59 -05:00
parent 8d5a08fd35
commit 58c6d5607f
GPG Key ID: D47306D7062CDA9D
3 changed files with 46 additions and 0 deletions
internal/parser

View File

@ -4,6 +4,7 @@ import (
_ "github.com/joint-online-judge/JOJ3/internal/parser/clangtidy"
_ "github.com/joint-online-judge/JOJ3/internal/parser/cppcheck"
_ "github.com/joint-online-judge/JOJ3/internal/parser/cpplint"
_ "github.com/joint-online-judge/JOJ3/internal/parser/debug"
_ "github.com/joint-online-judge/JOJ3/internal/parser/diff"
_ "github.com/joint-online-judge/JOJ3/internal/parser/dummy"
_ "github.com/joint-online-judge/JOJ3/internal/parser/healthcheck"

View File

@ -0,0 +1,9 @@
package debug
import "github.com/joint-online-judge/JOJ3/internal/stage"
var name = "debug"
func init() {
stage.RegisterParser(name, &Debug{})
}

View File

@ -0,0 +1,36 @@
package debug
import (
"log/slog"
"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 {
slog.Debug("debug parser file", "name", name, "content", content)
}
return stage.ParserResult{
Score: 0,
Comment: "",
}
}
func (*Debug) Run(results []stage.ExecutorResult, confAny any) (
[]stage.ParserResult, bool, error,
) {
conf, err := stage.DecodeConf[Conf](confAny)
if err != nil {
return nil, true, err
}
var res []stage.ParserResult
for _, result := range results {
res = append(res, Parse(result, *conf))
}
return res, false, nil
}