clang-tidy parser and executor #26
|
@ -53,9 +53,12 @@ func TestMain(t *testing.T) {
|
||||||
{Score: 100, Comment: "executor status: run time: \\d+ ns, memory: \\d+ bytes"},
|
{Score: 100, Comment: "executor status: run time: \\d+ ns, memory: \\d+ bytes"},
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
{"clang_tidy", []stage.StageResult{
|
{"clang-tidy", []stage.StageResult{
|
||||||
zjc_he marked this conversation as resolved
Outdated
|
|||||||
|
{Name: "prepare", Results: []stage.ParserResult{
|
||||||
|
{Score: 0, Comment: ""},
|
||||||
|
}},
|
||||||
{Name: "clang-tidy", Results: []stage.ParserResult{
|
{Name: "clang-tidy", Results: []stage.ParserResult{
|
||||||
{Score: -200, Comment: ""},
|
{Score: 10, Comment: ""},
|
||||||
}},
|
}},
|
||||||
}},
|
}},
|
||||||
{"compile_error", []stage.StageResult{
|
{"compile_error", []stage.StageResult{
|
||||||
|
|
5
examples/clang-tidy/CMakeLists.txt
Normal file
5
examples/clang-tidy/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
cmake_minimum_required(VERSION 3.0)
|
||||||
|
|
||||||
|
project(MyProject)
|
||||||
|
|
||||||
|
add_executable(main sillycode.cpp)
|
62
examples/clang-tidy/conf.toml
Normal file
62
examples/clang-tidy/conf.toml
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
skipGitea = true
|
||||||
|
[[stages]]
|
||||||
|
name = "prepare"
|
||||||
|
[stages.executor]
|
||||||
|
name = "sandbox"
|
||||||
|
[stages.executor.with.default]
|
||||||
|
args = ["cmake", "-S", ".", "-DDRONE=ON", "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON", "-B", "build"]
|
||||||
|
env = ["PATH=/usr/bin:/bin"]
|
||||||
|
cpuLimit = 10_000_000_000
|
||||||
|
memoryLimit = 104_857_600
|
||||||
|
procLimit = 50
|
||||||
|
copyInCwd = true
|
||||||
|
copyOut = ["stdout"]
|
||||||
|
copyOutCached = ["build/compile_commands.json"]
|
||||||
|
[stages.executor.with.default.stdin]
|
||||||
|
content = ""
|
||||||
|
[stages.executor.with.default.stdout]
|
||||||
|
name = "stdout"
|
||||||
|
max = 65_536
|
||||||
|
[stages.executor.with.default.stderr]
|
||||||
|
name = "stderr"
|
||||||
|
max = 65_536
|
||||||
|
[stages.parser]
|
||||||
|
name = "dummy"
|
||||||
|
[stages.parser.with]
|
||||||
|
score = 0
|
||||||
|
comment = ""
|
||||||
|
[[stages]]
|
||||||
|
name = "clang-tidy"
|
||||||
|
[stages.executor]
|
||||||
|
name = "sandbox"
|
||||||
|
[stages.executor.with.default]
|
||||||
|
args = ["clang-tidy", "--header-filter=.*", "--quiet", "-checks=*", "sillycode.cpp", "-p", "build"]
|
||||||
|
env = ["PATH=/usr/bin:/bin"]
|
||||||
|
cpuLimit = 10_000_000_000
|
||||||
|
memoryLimit = 104_857_600
|
||||||
|
procLimit = 50
|
||||||
|
copyInCwd = true
|
||||||
|
copyOut = ["stdout"]
|
||||||
|
[stages.executor.with.default.stdin]
|
||||||
|
content = ""
|
||||||
|
[stages.executor.with.default.stdout]
|
||||||
|
name = "stdout"
|
||||||
|
max = 65_536
|
||||||
|
[stages.executor.with.default.stderr]
|
||||||
|
name = "stderr"
|
||||||
|
max = 65_536
|
||||||
|
[stages.executor.with.default.copyInCached]
|
||||||
|
"build/compile_commands.json" = "build/compile_commands.json"
|
||||||
|
[stages.parser]
|
||||||
|
name = "clang-tidy"
|
||||||
|
[stages.parser.with]
|
||||||
|
score = 100
|
||||||
|
[[stages.parser.with.matches]]
|
||||||
|
keyword = ["cppcoreguidelines-avoid-non-const-global-variables"]
|
||||||
|
score = 5
|
||||||
|
[[stages.parser.with.matches]]
|
||||||
|
keyword = ["readability-identifier-length","misc-use-anonymous-namespace"]
|
||||||
|
score = 2
|
||||||
|
[[stages.parser.with.matches]]
|
||||||
|
keyword = ["llvmlibc-implementation-in-namespace"]
|
||||||
|
score = 0
|
1996
examples/clang_tidy/clangtidy_result.json
Normal file
1996
examples/clang_tidy/clangtidy_result.json
Normal file
File diff suppressed because it is too large
Load Diff
|
@ -1,32 +0,0 @@
|
||||||
skipGitea = true
|
|
||||||
[[stages]]
|
|
||||||
name = "clang-tidy"
|
|
||||||
[stages.executor]
|
|
||||||
name = "clang-tidy"
|
|
||||||
[stages.executor.with.default]
|
|
||||||
args = ["clang-tidy", "--header-filter=.*", "--quiet", "-checks=*", "sillycode.cpp"]
|
|
||||||
env = ["PATH=/usr/bin:/bin"]
|
|
||||||
[stages.executor.with.default.copyIn.dummy]
|
|
||||||
src = "./../../build/dummy"
|
|
||||||
copyOut = ["stdout", "stderr"]
|
|
||||||
[stages.executor.with.default.stdin]
|
|
||||||
content = ""
|
|
||||||
[stages.executor.with.default.stdout]
|
|
||||||
name = "stdout"
|
|
||||||
max = 65_536
|
|
||||||
[stages.executor.with.default.stderr]
|
|
||||||
name = "stderr"
|
|
||||||
max = 65_536
|
|
||||||
[stages.parser]
|
|
||||||
name = "clang-tidy"
|
|
||||||
[stages.parser.with]
|
|
||||||
score = 100
|
|
||||||
[[stages.parser.with.matches]]
|
|
||||||
keyword = ["cppcoreguidelines-avoid-non-const-global-variables"]
|
|
||||||
score = 5
|
|
||||||
[[stages.parser.with.matches]]
|
|
||||||
keyword = ["readability-identifier-length","misc-use-anonymous-namespace"]
|
|
||||||
score = 2
|
|
||||||
[[stages.parser.with.matches]]
|
|
||||||
keyword = ["llvmlibc-implementation-in-namespace"]
|
|
||||||
score = 0
|
|
|
@ -2,7 +2,6 @@
|
||||||
package clang_tidy
|
package clang_tidy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -111,7 +110,8 @@ func group_messages(messages []ClangMessage) []ClangMessage {
|
||||||
}
|
}
|
||||||
|
|
||||||
func convert_paths_to_relative(messages *[]ClangMessage) {
|
func convert_paths_to_relative(messages *[]ClangMessage) {
|
||||||
currentDir, _ := os.Getwd()
|
// currentDir, _ := os.Getwd()
|
||||||
zjc_he marked this conversation as resolved
Outdated
张泊明518370910136
commented
I think it should be part of the config file with default value I think it should be part of the config file with default value `"/w"`. Since the work dir in the sandbox can also be changed, it should not be hardcoded.
|
|||||||
|
currentDir := "/w"
|
||||||
for i := range *messages {
|
for i := range *messages {
|
||||||
(*messages)[i].filepath, _ = filepath.Rel(currentDir, (*messages)[i].filepath)
|
(*messages)[i].filepath, _ = filepath.Rel(currentDir, (*messages)[i].filepath)
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,10 @@ package clang_tidy
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
|
||||||
"os"
|
"os"
|
||||||
"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 {
|
||||||
|
@ -24,7 +22,6 @@ 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)
|
messages := parse_lines(lines)
|
||||||
|
@ -39,15 +36,15 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult {
|
||||||
encoder.SetIndent("", " ")
|
encoder.SetIndent("", " ")
|
||||||
_ = encoder.Encode(formatted_messages)
|
_ = encoder.Encode(formatted_messages)
|
||||||
|
|
||||||
if executorResult.Status != stage.Status(envexec.StatusAccepted) {
|
// if executorResult.Status != stage.Status(envexec.StatusAccepted) {
|
||||||
return stage.ParserResult{
|
// return stage.ParserResult{
|
||||||
Score: 0,
|
// Score: 0,
|
||||||
Comment: fmt.Sprintf(
|
// Comment: fmt.Sprintf(
|
||||||
"Unexpected executor status: %s.\nStderr: %s",
|
// "Unexpected executor status: %s.\nStderr: %s",
|
||||||
executorResult.Status, stderr,
|
// executorResult.Status, stderr,
|
||||||
),
|
// ),
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return stage.ParserResult{
|
return stage.ParserResult{
|
||||||
Score: get_score(formatted_messages, conf),
|
Score: get_score(formatted_messages, conf),
|
||||||
Comment: "",
|
Comment: "",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user
ditto