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