diff --git a/.gitmodules b/.gitmodules index d6f32b0..4c093ae 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,14 +10,14 @@ path = examples/compile/error url = ssh://git@focs.ji.sjtu.edu.cn:2222/FOCS-dev/JOJ3-examples.git branch = compile/error -[submodule "examples/dummy/success"] - path = examples/dummy/success +[submodule "examples/sample/success"] + path = examples/sample/success url = ssh://git@focs.ji.sjtu.edu.cn:2222/FOCS-dev/JOJ3-examples.git - branch = dummy/success -[submodule "examples/dummy/error"] - path = examples/dummy/error + branch = sample/success +[submodule "examples/sample/error"] + path = examples/sample/error url = ssh://git@focs.ji.sjtu.edu.cn:2222/FOCS-dev/JOJ3-examples.git - branch = dummy/error + branch = sample/error [submodule "examples/keyword/cpplint/sillycode"] path = examples/keyword/cpplint/sillycode url = ssh://git@focs.ji.sjtu.edu.cn:2222/FOCS-dev/JOJ3-examples.git diff --git a/README.md b/README.md index 296d0eb..7416adf 100644 --- a/README.md +++ b/README.md @@ -40,35 +40,7 @@ Note: you may fail the test if the checking tools are not installed. e.g. For th ```bash $ make test go test -coverprofile cover.out -v ./... - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/cmd/dummy coverage: 0.0% of statements -? focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors [no test files] -? focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers [no test files] -? focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/pkg/healthcheck [no test files] - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors/dummy coverage: 0.0% of statements - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/cpplint coverage: 0.0% of statements - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/diff coverage: 0.0% of statements - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage coverage: 0.0% of statements - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/pkg/dummy coverage: 0.0% of statements - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/keyword coverage: 0.0% of statements - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/dummy coverage: 0.0% of statements - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/executors/sandbox coverage: 0.0% of statements - focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/resultstatus coverage: 0.0% of statements -=== RUN TestMain -=== RUN TestMain/compile/error -=== RUN TestMain/compile/success -=== RUN TestMain/cpplint/sillycode -=== RUN TestMain/dummy/error -=== RUN TestMain/dummy/success -=== RUN TestMain/keyword/clang-tidy/sillycode -=== RUN TestMain/keyword/cpplint/sillycode ---- PASS: TestMain (2.28s) - --- PASS: TestMain/compile/error (0.03s) - --- PASS: TestMain/compile/success (0.42s) - --- PASS: TestMain/cpplint/sillycode (0.14s) - --- PASS: TestMain/dummy/error (0.01s) - --- PASS: TestMain/dummy/success (0.01s) - --- PASS: TestMain/keyword/clang-tidy/sillycode (1.57s) - --- PASS: TestMain/keyword/cpplint/sillycode (0.11s) +... PASS coverage: 74.0% of statements ok focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/cmd/joj3 2.290s coverage: 74.0% of statements diff --git a/cmd/dummy/main.go b/cmd/sample/main.go similarity index 74% rename from cmd/dummy/main.go rename to cmd/sample/main.go index 63f0d2c..5f2495e 100644 --- a/cmd/dummy/main.go +++ b/cmd/sample/main.go @@ -6,13 +6,13 @@ import ( "fmt" "os" - "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/pkg/dummy" + "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/pkg/sample" ) func main() { score := flag.Int("score", 0, "score") flag.Parse() - res, err := dummy.Run(dummy.Conf{Score: *score}) + res, err := sample.Run(sample.Conf{Score: *score}) if err != nil { fmt.Fprint(os.Stderr, err) os.Exit(1) diff --git a/examples/dummy/error b/examples/dummy/error deleted file mode 160000 index 8571a8b..0000000 --- a/examples/dummy/error +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8571a8ba30fb2c431d504ed9cfc74d33b9820246 diff --git a/examples/dummy/success b/examples/dummy/success deleted file mode 160000 index a933d18..0000000 --- a/examples/dummy/success +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a933d18dda38446d96e36ec5032c6dd48546511b diff --git a/examples/sample/error b/examples/sample/error new file mode 160000 index 0000000..aa5bf33 --- /dev/null +++ b/examples/sample/error @@ -0,0 +1 @@ +Subproject commit aa5bf333e30c9c0175e021c001d85f90092d7d1a diff --git a/examples/sample/success b/examples/sample/success new file mode 160000 index 0000000..ed17357 --- /dev/null +++ b/examples/sample/success @@ -0,0 +1 @@ +Subproject commit ed17357671e1c6f8aa7f534a482d9b2fac76d959 diff --git a/internal/parsers/all.go b/internal/parsers/all.go index 615f90c..f1404a7 100644 --- a/internal/parsers/all.go +++ b/internal/parsers/all.go @@ -5,9 +5,9 @@ import ( _ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/cppcheck" _ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/cpplint" _ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/diff" - _ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/dummy" _ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/keyword" _ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/resultstatus" + _ "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/parsers/sample" ) // this file does nothing but imports to ensure all the init() functions diff --git a/internal/parsers/dummy/meta.go b/internal/parsers/sample/meta.go similarity index 52% rename from internal/parsers/dummy/meta.go rename to internal/parsers/sample/meta.go index fd9ba75..b71de68 100644 --- a/internal/parsers/dummy/meta.go +++ b/internal/parsers/sample/meta.go @@ -1,9 +1,9 @@ -package dummy +package sample import "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage" -var name = "dummy" +var name = "sample" func init() { - stage.RegisterParser(name, &Dummy{}) + stage.RegisterParser(name, &Sample{}) } diff --git a/internal/parsers/dummy/parser.go b/internal/parsers/sample/parser.go similarity index 75% rename from internal/parsers/dummy/parser.go rename to internal/parsers/sample/parser.go index 26c75c5..70763c9 100644 --- a/internal/parsers/dummy/parser.go +++ b/internal/parsers/sample/parser.go @@ -1,11 +1,11 @@ -package dummy +package sample import ( "encoding/json" "fmt" "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/internal/stage" - "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/pkg/dummy" + "focs.ji.sjtu.edu.cn/git/FOCS-dev/JOJ3/pkg/sample" "github.com/criyle/go-judge/envexec" ) @@ -14,7 +14,7 @@ type Conf struct { Comment string } -type Dummy struct{} +type Sample struct{} func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { stdout := executorResult.Files["stdout"] @@ -28,8 +28,8 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { ), } } - var dummyResult dummy.Result - err := json.Unmarshal([]byte(stdout), &dummyResult) + var sampleResult sample.Result + err := json.Unmarshal([]byte(stdout), &sampleResult) if err != nil { return stage.ParserResult{ Score: 0, @@ -37,12 +37,12 @@ func Parse(executorResult stage.ExecutorResult, conf Conf) stage.ParserResult { } } return stage.ParserResult{ - Score: dummyResult.Score + conf.Score, - Comment: dummyResult.Comment + conf.Comment, + Score: sampleResult.Score + conf.Score, + Comment: sampleResult.Comment + conf.Comment, } } -func (*Dummy) Run(results []stage.ExecutorResult, confAny any) ( +func (*Sample) Run(results []stage.ExecutorResult, confAny any) ( []stage.ParserResult, bool, error, ) { conf, err := stage.DecodeConf[Conf](confAny) diff --git a/pkg/dummy/dummy.go b/pkg/sample/sample.go similarity index 82% rename from pkg/dummy/dummy.go rename to pkg/sample/sample.go index 938a7f4..6c9ab5a 100644 --- a/pkg/dummy/dummy.go +++ b/pkg/sample/sample.go @@ -1,4 +1,4 @@ -package dummy +package sample import ( "fmt" @@ -19,10 +19,10 @@ func Run(conf Conf) (res Result, err error) { // the sandbox, the logs will not show in drone output directly. // If there are more kinds of errors need to be handled separately, add // more fields in the Result struct, don't mess everything up in Stderr. - err = fmt.Errorf("dummy negative score: %d", conf.Score) + err = fmt.Errorf("sample negative score: %d", conf.Score) return } res.Score = conf.Score - res.Comment = "dummy comment" + res.Comment = "sample comment" return }