chore: rename dummy -> sample

This commit is contained in:
张泊明518370910136 2024-09-10 21:59:17 -04:00
parent f81581b928
commit 2928e6321f
GPG Key ID: D47306D7062CDA9D
11 changed files with 26 additions and 54 deletions

12
.gitmodules vendored
View File

@ -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

View File

@ -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

View File

@ -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)

@ -1 +0,0 @@
Subproject commit 8571a8ba30fb2c431d504ed9cfc74d33b9820246

@ -1 +0,0 @@
Subproject commit a933d18dda38446d96e36ec5032c6dd48546511b

1
examples/sample/error Submodule

@ -0,0 +1 @@
Subproject commit aa5bf333e30c9c0175e021c001d85f90092d7d1a

@ -0,0 +1 @@
Subproject commit ed17357671e1c6f8aa7f534a482d9b2fac76d959

View File

@ -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

View File

@ -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{})
}

View File

@ -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)

View File

@ -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
}