fix(internal/parsers/clang_tidy/parser.go): check the return value of executor, if not 0 or 1 then report error
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing

This commit is contained in:
张佳澈520370910044 2024-05-07 16:03:49 +08:00
parent 09024b4c15
commit 6429d820a9
2 changed files with 16 additions and 11 deletions

@ -1 +1 @@
Subproject commit 580d9c9e20ae887551af2f87483d82cf6efa6f6d Subproject commit 4b00eacf88277a06bbb5052e5b2688cd622521d0

View File

@ -1,9 +1,11 @@
package clang_tidy package clang_tidy
import ( import (
"fmt"
"strings" "strings"
"focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage" "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage"
"github.com/criyle/go-judge/envexec"
) )
type Match struct { type Match struct {
@ -21,21 +23,24 @@ type ClangTidy 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"]
lines := strings.SplitAfter(stdout, "\n") lines := strings.SplitAfter(stdout, "\n")
messages := parse_lines(lines, conf) messages := parse_lines(lines, conf)
formatted_messages := format(messages) formatted_messages := format(messages)
// TODO: Handle unexpected errors from executor if executorResult.Status != stage.Status(envexec.StatusAccepted) {
// if executorResult.Status != stage.Status(envexec.StatusAccepted) { if !((executorResult.Status == stage.Status(envexec.StatusNonzeroExitStatus)) &&
// return stage.ParserResult{ (executorResult.ExitStatus == 1)) {
// Score: 0, return stage.ParserResult{
// Comment: fmt.Sprintf( Score: 0,
// "Unexpected executor status: %s.\nStderr: %s", Comment: fmt.Sprintf(
// executorResult.Status, stderr, "Unexpected executor status: %s.\nStderr: %s",
// ), executorResult.Status, stderr,
// } ),
// } }
}
}
return stage.ParserResult{ return stage.ParserResult{
Score: get_score(formatted_messages, conf), Score: get_score(formatted_messages, conf),
Comment: get_comment(formatted_messages), Comment: get_comment(formatted_messages),