feat: support for custom stdin

This commit is contained in:
李衍志523370910113 2024-11-14 10:35:33 +08:00
parent 69b9af03a0
commit 303c9d8e40
4 changed files with 80 additions and 61 deletions

View File

@ -50,6 +50,8 @@ class Stage(BaseModel):
name: Optional[str] = None # Stage name name: Optional[str] = None # Stage name
command: Optional[str] = None # Command to run command: Optional[str] = None # Command to run
files: Optional[Files] = None files: Optional[Files] = None
in_: Optional[str] = Field(None, alias="in")
out_: Optional[str] = Field(None, alias="out")
score: Optional[int] = 0 score: Optional[int] = 0
parsers: Optional[list[str]] = [] # list of parsers parsers: Optional[list[str]] = [] # list of parsers
limit: Optional[Limit] = Limit() limit: Optional[Limit] = Limit()

View File

@ -234,12 +234,28 @@ def fix_diff(
if case_stage.limit and case_stage.limit.mem is not None if case_stage.limit and case_stage.limit.mem is not None
else 0 else 0
) )
command = (
case_stage.command
if case_stage.command is not None
else None
)
stdin = (
case_stage.in_
if case_stage.in_ is not None
else f"{case}.in"
)
stdout = (
case_stage.out_
if case_stage.out_ is not None
else f"{case}.out"
)
stage_cases.append( stage_cases.append(
result.OptionalCmd( result.OptionalCmd(
stdin=result.CmdFile( stdin=result.CmdFile(
src=f"/home/tt/.config/joj/{task_conf.task.type_}/{case}.in" src=f"/home/tt/.config/joj/{task_conf.task.type_}/{stdin}"
), ),
args=shlex.split(case_stage.command) if command is not None else None,
cpu_limit=cpu_limit, cpu_limit=cpu_limit,
clock_limit=clock_limit, clock_limit=clock_limit,
memory_limit=memory_limit, memory_limit=memory_limit,
@ -260,7 +276,7 @@ def fix_diff(
{ {
"score": diff_output.score, "score": diff_output.score,
"fileName": "stdout", "fileName": "stdout",
"answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{case}.out", "answerPath": f"/home/tt/.config/joj/{task_conf.task.type_}/{stdout}",
"forceQuitOnDiff": diff_output.forcequit, "forceQuitOnDiff": diff_output.forcequit,
"alwaysHide": diff_output.hide, "alwaysHide": diff_output.hide,
"compareSpace": not diff_output.ignorespaces, "compareSpace": not diff_output.ignorespaces,

View File

@ -145,9 +145,9 @@
], ],
"copyOutCached": [ "copyOutCached": [
"h6/build/ex3", "h6/build/ex3",
"h6/build/asan", "h6/build/ex3-asan",
"h6/build/ubsan", "h6/build/ex3-ubsan",
"h6/build/msan", "h6/build/ex3-msan",
"h6/build/compile_commands.json" "h6/build/compile_commands.json"
], ],
"copyOutMax": 0, "copyOutMax": 0,
@ -248,9 +248,9 @@
}, },
"copyInCached": { "copyInCached": {
"h6/build/ex3": "h6/build/ex3", "h6/build/ex3": "h6/build/ex3",
"h6/build/asan": "h6/build/asan", "h6/build/ex3-asan": "h6/build/ex3-asan",
"h6/build/ubsan": "h6/build/ubsan", "h6/build/ex3-ubsan": "h6/build/ex3-ubsan",
"h6/build/msan": "h6/build/msan", "h6/build/ex3-msan": "h6/build/ex3-msan",
"h6/build/compile_commands.json": "h6/build/compile_commands.json" "h6/build/compile_commands.json": "h6/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
@ -369,9 +369,9 @@
}, },
"copyInCached": { "copyInCached": {
"h6/build/ex3": "h6/build/ex3", "h6/build/ex3": "h6/build/ex3",
"h6/build/asan": "h6/build/asan", "h6/build/ex3-asan": "h6/build/ex3-asan",
"h6/build/ubsan": "h6/build/ubsan", "h6/build/ex3-ubsan": "h6/build/ex3-ubsan",
"h6/build/msan": "h6/build/msan", "h6/build/ex3-msan": "h6/build/ex3-msan",
"h6/build/compile_commands.json": "h6/build/compile_commands.json" "h6/build/compile_commands.json": "h6/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
@ -509,9 +509,9 @@
"copyIn": {}, "copyIn": {},
"copyInCached": { "copyInCached": {
"h6/build/ex3": "h6/build/ex3", "h6/build/ex3": "h6/build/ex3",
"h6/build/asan": "h6/build/asan", "h6/build/ex3-asan": "h6/build/ex3-asan",
"h6/build/ubsan": "h6/build/ubsan", "h6/build/ex3-ubsan": "h6/build/ex3-ubsan",
"h6/build/msan": "h6/build/msan", "h6/build/ex3-msan": "h6/build/ex3-msan",
"h6/build/compile_commands.json": "h6/build/compile_commands.json" "h6/build/compile_commands.json": "h6/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
@ -625,9 +625,9 @@
"copyIn": {}, "copyIn": {},
"copyInCached": { "copyInCached": {
"h6/build/ex3": "h6/build/ex3", "h6/build/ex3": "h6/build/ex3",
"h6/build/asan": "h6/build/asan", "h6/build/ex3-asan": "h6/build/ex3-asan",
"h6/build/ubsan": "h6/build/ubsan", "h6/build/ex3-ubsan": "h6/build/ex3-ubsan",
"h6/build/msan": "h6/build/msan", "h6/build/ex3-msan": "h6/build/ex3-msan",
"h6/build/compile_commands.json": "h6/build/compile_commands.json" "h6/build/compile_commands.json": "h6/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
@ -705,7 +705,7 @@
"with": { "with": {
"default": { "default": {
"args": [ "args": [
"./h6/build/asan", "./h6/build/ex3-asan",
"-a" "-a"
], ],
"env": [ "env": [
@ -743,9 +743,9 @@
"copyIn": {}, "copyIn": {},
"copyInCached": { "copyInCached": {
"h6/build/ex3": "h6/build/ex3", "h6/build/ex3": "h6/build/ex3",
"h6/build/asan": "h6/build/asan", "h6/build/ex3-asan": "h6/build/ex3-asan",
"h6/build/ubsan": "h6/build/ubsan", "h6/build/ex3-ubsan": "h6/build/ex3-ubsan",
"h6/build/msan": "h6/build/msan", "h6/build/ex3-msan": "h6/build/ex3-msan",
"h6/build/compile_commands.json": "h6/build/compile_commands.json" "h6/build/compile_commands.json": "h6/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
@ -795,7 +795,7 @@
"with": { "with": {
"default": { "default": {
"args": [ "args": [
"./h6/build/msan", "./h6/build/ex3-msan",
"-a" "-a"
], ],
"env": [ "env": [
@ -833,9 +833,9 @@
"copyIn": {}, "copyIn": {},
"copyInCached": { "copyInCached": {
"h6/build/ex3": "h6/build/ex3", "h6/build/ex3": "h6/build/ex3",
"h6/build/asan": "h6/build/asan", "h6/build/ex3-asan": "h6/build/ex3-asan",
"h6/build/ubsan": "h6/build/ubsan", "h6/build/ex3-ubsan": "h6/build/ex3-ubsan",
"h6/build/msan": "h6/build/msan", "h6/build/ex3-msan": "h6/build/ex3-msan",
"h6/build/compile_commands.json": "h6/build/compile_commands.json" "h6/build/compile_commands.json": "h6/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
@ -885,7 +885,7 @@
"with": { "with": {
"default": { "default": {
"args": [ "args": [
"./h6/build/ubsan", "./h6/build/ex3-ubsan",
"-a" "-a"
], ],
"env": [ "env": [
@ -923,9 +923,9 @@
"copyIn": {}, "copyIn": {},
"copyInCached": { "copyInCached": {
"h6/build/ex3": "h6/build/ex3", "h6/build/ex3": "h6/build/ex3",
"h6/build/asan": "h6/build/asan", "h6/build/ex3-asan": "h6/build/ex3-asan",
"h6/build/ubsan": "h6/build/ubsan", "h6/build/ex3-ubsan": "h6/build/ex3-ubsan",
"h6/build/msan": "h6/build/msan", "h6/build/ex3-msan": "h6/build/ex3-msan",
"h6/build/compile_commands.json": "h6/build/compile_commands.json" "h6/build/compile_commands.json": "h6/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
@ -1012,9 +1012,9 @@
"copyIn": {}, "copyIn": {},
"copyInCached": { "copyInCached": {
"h6/build/ex3": "h6/build/ex3", "h6/build/ex3": "h6/build/ex3",
"h6/build/asan": "h6/build/asan", "h6/build/ex3-asan": "h6/build/ex3-asan",
"h6/build/ubsan": "h6/build/ubsan", "h6/build/ex3-ubsan": "h6/build/ex3-ubsan",
"h6/build/msan": "h6/build/msan", "h6/build/ex3-msan": "h6/build/ex3-msan",
"h6/build/compile_commands.json": "h6/build/compile_commands.json" "h6/build/compile_commands.json": "h6/build/compile_commands.json"
}, },
"copyInDir": ".", "copyInDir": ".",
@ -1040,7 +1040,7 @@
"PATH=/usr/bin:/bin:/usr/local/bin" "PATH=/usr/bin:/bin:/usr/local/bin"
], ],
"stdin": { "stdin": {
"src": "/home/tt/.config/joj/tests/homework/h6/e3/case0.in", "src": "/home/tt/.config/joj/tests/homework/h6/e3/paragraph.in",
"max": 419430400, "max": 419430400,
"streamIn": true, "streamIn": true,
"streamOut": true, "streamOut": true,
@ -1207,7 +1207,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 5,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case0.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case0.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,
@ -1219,7 +1219,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 5,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case1.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case1.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,
@ -1231,7 +1231,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 5,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case2.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case2.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,
@ -1243,7 +1243,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 5,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case3.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case3.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,
@ -1255,7 +1255,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 10,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case4.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case4.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,
@ -1267,7 +1267,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 10,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case5.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case5.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,
@ -1279,7 +1279,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 15,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case6.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case6.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,
@ -1291,7 +1291,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 15,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case7.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case7.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,
@ -1303,7 +1303,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 15,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case8.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case8.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,
@ -1315,7 +1315,7 @@
{ {
"outputs": [ "outputs": [
{ {
"score": 0, "score": 15,
"fileName": "stdout", "fileName": "stdout",
"answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case9.out", "answerPath": "/home/tt/.config/joj/tests/homework/h6/e3/case9.out",
"forceQuitOnDiff": true, "forceQuitOnDiff": true,

View File

@ -9,7 +9,7 @@ release.stages = [ "compile" ]
name = "Compilation" name = "Compilation"
command = "./tools/compile" # eg. script running cmake commands command = "./tools/compile" # eg. script running cmake commands
files.import = [ "tools/compile" ] files.import = [ "tools/compile" ]
files.export = [ "h6/build/ex3", "h6/build/asan", "h6/build/ubsan", "h6/build/msan", "h6/build/compile_commands.json" ] files.export = [ "h6/build/ex3", "h6/build/ex3-asan", "h6/build/ex3-ubsan", "h6/build/ex3-msan", "h6/build/compile_commands.json" ]
# compile parsers # compile parsers
parsers = [ "result-detail", "dummy", "result-status" ] parsers = [ "result-detail", "dummy", "result-status" ]
@ -80,8 +80,8 @@ result-detail.mem = false
[[stages]] [[stages]]
name = "[run] address sanitizer" name = "[run] address sanitizer"
group = "run" group = "run"
command="./h6/build/asan -a" command="./h6/build/ex3-asan -a"
files.import = [ "h6/build/asan" ] files.import = [ "h6/build/ex3-asan" ]
parsers = [ "result-status", "result-detail" ] parsers = [ "result-status", "result-detail" ]
result-status.score = 1 result-status.score = 1
@ -92,8 +92,8 @@ result-detail.stderr = true
[[stages]] [[stages]]
name = "[run] memory sanitizer" name = "[run] memory sanitizer"
group = "run" group = "run"
command="./h6/build/msan -a" command="./h6/build/ex3-msan -a"
files.import = [ "h6/build/msan" ] files.import = [ "h6/build/ex3-msan" ]
parsers = [ "result-status", "result-detail" ] parsers = [ "result-status", "result-detail" ]
result-status.score = 1 result-status.score = 1
@ -103,8 +103,8 @@ result-detail.stderr = true
[[stages]] [[stages]]
name = "[run] undefined behavior sanitizer" name = "[run] undefined behavior sanitizer"
command="./h6/build/ubsan -a" command="./h6/build/ex3-ubsan -a"
files.import = [ "h6/build/ubsan" ] files.import = [ "h6/build/ex3-ubsan" ]
parsers = [ "result-status", "result-detail" ] parsers = [ "result-status", "result-detail" ]
result-status.score = 1 result-status.score = 1
@ -124,53 +124,54 @@ result-detail.exitstatus = true
result-detail.stderr = true result-detail.stderr = true
# will be removed as long as the name is fixed # will be removed as long as the name is fixed
case0.score = 10 case0.in = "paragraph.in"
case0.command = "Manuel Charlemagne"
case0.diff.output.score = 5
case0.limit.cpu = 30 case0.limit.cpu = 30
case0.limit.mem = 32 case0.limit.mem = 32
case0.limit.stdout = 8 case0.limit.stdout = 8
case0.command = "Manuel Charlemagne"
case1.score = 10 case1.diff.output.score = 5
case1.limit.cpu = 30 case1.limit.cpu = 30
case1.limit.mem = 32 case1.limit.mem = 32
case1.limit.stdout = 8 case1.limit.stdout = 8
case2.score = 10 case2.diff.output.score = 5
case2.limit.cpu = 30 case2.limit.cpu = 30
case2.limit.mem = 32 case2.limit.mem = 32
case2.limit.stdout = 8 case2.limit.stdout = 8
case3.score = 10 case3.diff.output.score = 5
case3.limit.cpu = 30 case3.limit.cpu = 30
case3.limit.mem = 32 case3.limit.mem = 32
case3.limit.stdout = 8 case3.limit.stdout = 8
case4.score = 10 case4.diff.output.score = 10
case4.limit.cpu = 30 case4.limit.cpu = 30
case4.limit.mem = 32 case4.limit.mem = 32
case4.limit.stdout = 8 case4.limit.stdout = 8
case5.score = 10 case5.diff.output.score = 10
case5.limit.cpu = 30 case5.limit.cpu = 30
case5.limit.mem = 32 case5.limit.mem = 32
case5.limit.stdout = 8 case5.limit.stdout = 8
case6.score = 10 case6.diff.output.score = 15
case6.limit.cpu = 30 case6.limit.cpu = 30
case6.limit.mem = 32 case6.limit.mem = 32
case6.limit.stdout = 8 case6.limit.stdout = 8
case7.score = 10 case7.diff.output.score = 15
case7.limit.cpu = 30 case7.limit.cpu = 30
case7.limit.mem = 32 case7.limit.mem = 32
case7.limit.stdout = 8 case7.limit.stdout = 8
case8.score = 10 case8.diff.output.score = 15
case8.limit.cpu = 30 case8.limit.cpu = 30
case8.limit.mem = 32 case8.limit.mem = 32
case8.limit.stdout = 8 case8.limit.stdout = 8
case9.score = 10 case9.diff.output.score = 15
case9.limit.cpu = 30 case9.limit.cpu = 30
case9.limit.mem = 32 case9.limit.mem = 32
case9.limit.stdout = 8 case9.limit.stdout = 8