From e68de4fcc5d4ac7efd206ad77e6a941283e4527c Mon Sep 17 00:00:00 2001 From: Boming Zhang Date: Sun, 3 Nov 2024 01:51:03 -0400 Subject: [PATCH] feat(parser): only check result status in resultstatus and healthcheck parser --- internal/parser/clangtidy/parser.go | 16 +--------------- internal/parser/cppcheck/parser.go | 11 ----------- internal/parser/healthcheck/parser.go | 2 +- internal/parser/sample/parser.go | 12 +----------- 4 files changed, 3 insertions(+), 38 deletions(-) diff --git a/internal/parser/clangtidy/parser.go b/internal/parser/clangtidy/parser.go index 455e3d3..58505d4 100644 --- a/internal/parser/clangtidy/parser.go +++ b/internal/parser/clangtidy/parser.go @@ -1,10 +1,8 @@ package clangtidy import ( - "fmt" "strings" - "github.com/criyle/go-judge/envexec" "github.com/joint-online-judge/JOJ3/internal/stage" ) @@ -26,19 +24,7 @@ type ClangTidy struct{} func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { stdout := executorResult.Files[conf.Stdout] - stderr := executorResult.Files[conf.Stderr] - if executorResult.Status != stage.Status(envexec.StatusAccepted) { - if !((executorResult.Status == stage.Status(envexec.StatusNonzeroExitStatus)) && - (executorResult.ExitStatus == 1)) { - return stage.ParserResult{ - Score: 0, - Comment: fmt.Sprintf( - "Unexpected executor status: %s.\nStderr: %s", - executorResult.Status, stderr, - ), - } - } - } + // stderr := executorResult.Files[conf.Stderr] lines := strings.SplitAfter(stdout, "\n") messages := ParseLines(lines, conf) formattedMessages := Format(messages) diff --git a/internal/parser/cppcheck/parser.go b/internal/parser/cppcheck/parser.go index 41cecb9..f90237b 100644 --- a/internal/parser/cppcheck/parser.go +++ b/internal/parser/cppcheck/parser.go @@ -5,7 +5,6 @@ import ( "fmt" "strings" - "github.com/criyle/go-judge/envexec" "github.com/joint-online-judge/JOJ3/internal/stage" ) @@ -37,16 +36,6 @@ type CppCheck struct{} func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { // stdout := executorResult.Files[conf.Stdout] stderr := executorResult.Files[conf.Stderr] - - if executorResult.Status != stage.Status(envexec.StatusAccepted) { - return stage.ParserResult{ - Score: 0, - Comment: fmt.Sprintf( - "Unexpected executor status: %s.\nStderr: %s", - executorResult.Status, stderr, - ), - } - } records := make([]Record, 0) lines := strings.Split(stderr, "\n") for _, line := range lines { diff --git a/internal/parser/healthcheck/parser.go b/internal/parser/healthcheck/parser.go index 0ebe1d3..7beac4f 100644 --- a/internal/parser/healthcheck/parser.go +++ b/internal/parser/healthcheck/parser.go @@ -21,7 +21,7 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) (stage.ParserResult, return stage.ParserResult{ Score: 0, Comment: fmt.Sprintf( - "Unexpected executor status: %s.\n`stdout`: ```%s\n```\n`stderr`: ```%s\n```", + "Unexpected executor status: %s.\n`stdout`:\n```%s\n```\n`stderr`:\n```%s\n```", executorResult.Status, stdout, stderr, ), }, true diff --git a/internal/parser/sample/parser.go b/internal/parser/sample/parser.go index 2eabf24..95a411f 100644 --- a/internal/parser/sample/parser.go +++ b/internal/parser/sample/parser.go @@ -4,7 +4,6 @@ import ( "encoding/json" "fmt" - "github.com/criyle/go-judge/envexec" "github.com/joint-online-judge/JOJ3/internal/stage" "github.com/joint-online-judge/JOJ3/pkg/sample" ) @@ -20,16 +19,7 @@ type Sample struct{} func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { stdout := executorResult.Files[conf.Stdout] - stderr := executorResult.Files[conf.Stderr] - if executorResult.Status != stage.Status(envexec.StatusAccepted) { - return stage.ParserResult{ - Score: 0, - Comment: fmt.Sprintf( - "Unexpected executor status: %s.\nStderr: %s", - executorResult.Status, stderr, - ), - } - } + // stderr := executorResult.Files[conf.Stderr] var sampleResult sample.Result err := json.Unmarshal([]byte(stdout), &sampleResult) if err != nil {