From c36977c3fa2415985d5baaef3cf5e2ae7dc14c96 Mon Sep 17 00:00:00 2001 From: Nuvole Date: Sat, 9 Nov 2024 13:08:08 +0800 Subject: [PATCH] feat: remove nulls function --- joj3_config_generator/lib/task.py | 11 +- joj3_config_generator/main.py | 2 + tests/convert/basic/repo.toml | 4 +- tests/convert/basic/task.json | 1228 +++++++++++---------------- tests/convert/basic/task.toml | 143 ++-- tests/convert/test_convert_cases.py | 2 - 6 files changed, 598 insertions(+), 792 deletions(-) diff --git a/joj3_config_generator/lib/task.py b/joj3_config_generator/lib/task.py index 1692f41..8666971 100644 --- a/joj3_config_generator/lib/task.py +++ b/joj3_config_generator/lib/task.py @@ -1,10 +1,19 @@ -from typing import Tuple +from typing import Any, Dict, Tuple import rtoml from joj3_config_generator.models import joj1, repo, result, task +def remove_nulls(d: Dict[str, Any]) -> Dict[str, Any]: + if isinstance(d, dict): + return {k: remove_nulls(v) for k, v in d.items() if v is not None} + elif isinstance(d, list): + return [remove_nulls(item) for item in d] + else: + return d + + def get_conf_stage( task_stage: task.Stage, executor_with_config: result.ExecutorWith ) -> result.StageDetail: diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 0e3f79c..d814496 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -9,6 +9,7 @@ import yaml from joj3_config_generator.convert import convert as convert_conf from joj3_config_generator.convert import convert_joj1 as convert_joj1_conf +from joj3_config_generator.lib.task import remove_nulls from joj3_config_generator.models import joj1, repo, result, task from joj3_config_generator.utils.logger import logger @@ -63,6 +64,7 @@ def convert(root: Path = Path(".")) -> result.Config: task_obj = rtoml.loads(task_toml) result_model = convert_conf(repo.Config(**repo_obj), task.Config(**task_obj)) result_dict = result_model.model_dump(by_alias=True) + result_dict = remove_nulls(result_dict) with open(result_json_path, "w") as result_file: json.dump(result_dict, result_file, ensure_ascii=False, indent=4) diff --git a/tests/convert/basic/repo.toml b/tests/convert/basic/repo.toml index 28b5c05..bb9818b 100644 --- a/tests/convert/basic/repo.toml +++ b/tests/convert/basic/repo.toml @@ -6,5 +6,5 @@ sandbox_token = "test" [files] whitelist_patterns = ["*.py", "*.txt", "*.md"] whitelist_file = ".whitelist" -required = ["main.py", "README.md"] -immutable = [] +required = [ "Changelog.md", "Readme.md" ] +immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] diff --git a/tests/convert/basic/task.json b/tests/convert/basic/task.json index a49a9d9..9277b16 100644 --- a/tests/convert/basic/task.json +++ b/tests/convert/basic/task.json @@ -1,6 +1,6 @@ { - "name": "Homework 1 exercise 2", - "logPath": "Homework-1-exercise-2.log", + "name": "p2 m3", + "logPath": "p2-m3.log", "expireUnixTimestamp": 1728748740, "stage": { "sandboxExecServer": "172.17.0.1:5051", @@ -18,42 +18,31 @@ "./repo-health-checker", "-root=.", "-repoSize=50.5", - "-meta=main.py", - "-meta=README.md", - "-checkFileSumList=-checkFileNameList=" + "-meta=Changelog.md", + "-meta=Readme.md", + "-checkFileSumList=a5b63323a692d3d8b952442969649b4f823d58dae26429494f613df160710dfc,b1bbad25b830db0a77b15a033f9ca1b7ab44c1d2d05056412bd3e4421645f0bf,1965adff52af61da8b9e089ff580d60f7e4c294a2930b9809c5cbdf76528de4d,c8bd62bf5297bac738b3845612fd595d677884093070904375463ab7953fce28", + "-checkFileNameList=.gitignore,.gitattributes,.gitea/workflows/push.yaml,.gitea/workflows/release.yaml" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4096, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4096, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -69,11 +58,7 @@ "copyIn": { "./repo-health-checker": { "src": "./repo-health-checker", - "content": null, - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -104,117 +89,144 @@ ] }, { - "name": "Compilation", - "group": null, + "name": "Abuse of strings detected", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "make.sh" + "./strdetect", + "src/" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", - "max": 128000000000, - "symlink": null, + "max": 4000000000, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 180000000000, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 360000000000, + "clockLimit": 8000000000, "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "tools/make.sh": { - "src": "/home/tt/.config/joj/tools/make.sh", - "content": null, - "fileId": null, - "name": null, + "tools/strdetec": { + "src": "/home/tt/.config/joj/tools/strdetec", "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/main.c": { - "src": "/home/tt/.config/joj/src/main.c", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "src/task.h": { - "src": "/home/tt/.config/joj/src/task.h", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "srcCMakelist.txt": { - "src": "/home/tt/.config/joj/srcCMakelist.txt", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false } }, "copyInCached": { - "tools/make.sh": "tools/make.sh", - "src/main.c": "src/main.c", - "src/task.h": "src/task.h", - "srcCMakelist.txt": "srcCMakelist.txt" + "tools/strdetec": "tools/strdetec" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true + } + } + ] + }, + { + "name": "Compilation", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "compile" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "tools/compile": { + "src": "/home/tt/.config/joj/tools/compile", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "tools/compile": "tools/compile" }, "copyInDir": ".", "copyOut": [], "copyOutCached": [ - "driver", - "p2", - "p2-msan" + "build/onecard", + "build/asan", + "build/ubsan", + "build/msan", + "build/compile_commands.json" ], "copyOutMax": 0, "copyOutDir": "", @@ -245,7 +257,7 @@ "with": { "score": 1, "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": false + "forceQuitOnNotAccepted": true } }, { @@ -253,22 +265,21 @@ "with": { "score": 1, "comment": "Congratulations! Your code compiled successfully.", - "forceQuitOnNotAccepted": false + "forceQuitOnNotAccepted": true } } ] }, { - "name": "File length check", - "group": null, + "name": "[cq] Filelength", "executor": { "name": "sandbox", "with": { "default": { "args": [ "./file-length", - "500", "400", + "300", "*.c", "*.h" ], @@ -276,34 +287,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -317,20 +316,16 @@ "cpuRateLimit": 0, "cpuSetLimit": "", "copyIn": { - "tools/file-length": { - "src": "/home/tt/.config/joj/tools/file-length", - "content": null, - "fileId": null, - "name": null, + "tools/filelength": { + "src": "/home/tt/.config/joj/tools/filelength", "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false } }, "copyInCached": { - "tools/file-length": "tools/file-length" + "tools/filelength": "tools/filelength" }, "copyInDir": ".", "copyOut": [], @@ -352,154 +347,15 @@ "matches": [ { "keywords": [ - "max" - ], - "score": 50 - }, - { - "keywords": [ - "recommend" - ], - "score": 20 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 10000, - "comment": "Manuel Charlemagne", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stderr" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "Clang-tidy checks", - "group": null, - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "run-clang-tidy-18", - "-header-filter=.*", - "-quiet", - "-load=/usr/local/lib/libcodequality.so", - "-p", - "build" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 65000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 4000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [] - } - }, - "parsers": [ - { - "name": "clangtidy", - "with": { - "matches": [ - { - "keywords": [ - "bugprone-suspicious-string-compare" - ], - "score": 8 - }, - { - "keywords": [ - "codequality-no-global-variables", - "codequality-no-header-guard", - "readability-duplicate-include", - "readability-misleading-indentation" + "recommended" ], "score": 10 }, { "keywords": [ - "readability-function-size" + "max" ], - "score": 50 - }, - { - "keywords": [ - "readability-identifier-naming", - "readability-redundant", - "readability-misplaced-array-index", - "cppcoreguidelines-init-variables", - "google-global-names-in-headers", - "clang-diagnostic", - "clang-analyzer", - "misc performance" - ], - "score": 5 + "score": 20 } ] } @@ -528,8 +384,147 @@ ] }, { - "name": "Cppcheck check", - "group": null, + "name": "[cq] Clang-tidy", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "run-clang-tidy-18", + "-header-filter=.*", + "-quiet", + "-load=/usr/local/lib/libcodequality.so", + "-p", + "build" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 65000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": { + "projects/p2/.clang-tidy": { + "src": "/home/tt/.config/joj/projects/p2/.clang-tidy", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + } + }, + "copyInCached": { + "projects/p2/.clang-tidy": "projects/p2/.clang-tidy" + }, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "clangtidy", + "with": { + "matches": [ + { + "keywords": [ + "readability-function-size" + ], + "score": 10 + }, + { + "keywords": [ + "codequality-no-global-variables", + "codequality-no-header-guard", + "codequality-no-fflush-stdin" + ], + "score": 20 + }, + { + "keywords": [ + "codequality-unchecked-malloc-result", + "readability-duplicate-include", + "readability-identifier-naming", + "readability-redundant", + "readability-misplaced-array-index", + "cppcoreguidelines-init-variables", + "bugprone-suspicious-string-compare", + "google-global-names-in-headers", + "clang-diagnostic", + "clang-analyzer", + "misc", + "performance", + "portability" + ], + "score": 5 + }, + { + "keywords": [ + "readability-misleading-indentation" + ], + "score": 15 + } + ] + } + }, + { + "name": "dummy", + "with": { + "score": 0, + "comment": "", + "forceQuitOnNotAccepted": true + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stdout" + ], + "showExitStatus": true, + "showRuntime": false, + "showMemory": false + } + } + ] + }, + { + "name": "[cq] Cppcheck", "executor": { "name": "sandbox", "with": { @@ -543,6 +538,7 @@ "\"id\":\"{id}\"}'", "--force", "--enable=all", + "--suppress=missingIncludeSystem", "--quiet", "./" ], @@ -550,34 +546,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 65000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -613,21 +597,16 @@ { "keywords": [ "warning", + "portability", + "performance", "style" ], - "score": 10 + "score": 5 }, { "keywords": [ "error" ], - "score": 20 - }, - { - "keywords": [ - "portability", - "performance" - ], "score": 15 } ] @@ -657,8 +636,7 @@ ] }, { - "name": "Cpplint check", - "group": null, + "name": "[cq] Cpplint", "executor": { "name": "sandbox", "with": { @@ -675,34 +653,22 @@ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 65000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false @@ -740,7 +706,7 @@ "matches": [ { "keywords": [ - "runtime" + "build" ], "score": 10 }, @@ -752,262 +718,9 @@ }, { "keywords": [ - "build" + "runtime" ], - "score": 15 - } - ] - } - }, - { - "name": "dummy", - "with": { - "score": 0, - "comment": "", - "forceQuitOnNotAccepted": true - } - }, - { - "name": "result-detail", - "with": { - "score": 0, - "comment": "", - "showFiles": [ - "stdout" - ], - "showExitStatus": true, - "showRuntime": false, - "showMemory": false - } - } - ] - }, - { - "name": "judge-base", - "group": "joj", - "executor": { - "name": "sandbox", - "with": { - "default": { - "args": [ - "./driver", - "./mumsh" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": null, - "content": "", - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": { - "src": null, - "content": null, - "fileId": null, - "name": "stdout", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stderr": { - "src": null, - "content": null, - "fileId": null, - "name": "stderr", - "max": 4000000000, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "cpuLimit": 3000000000, - "realCpuLimit": 0, - "clockLimit": 6000000000, - "memoryLimit": 78643200, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-base/case8.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] - } - }, - "parsers": [ - { - "name": "diff", - "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-base/case8.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] + "score": 5 } ] } @@ -1029,63 +742,50 @@ "stderr" ], "showExitStatus": true, - "showRuntime": true, - "showMemory": true + "showRuntime": false, + "showMemory": false } } ] }, { - "name": "judge-msan", - "group": "joj", + "name": "[run] onecard", "executor": { "name": "sandbox", "with": { "default": { "args": [ - "./driver", - "./mumsh-msan" + "./onecard", + "-a" ], "env": [ "PATH=/usr/bin:/bin:/usr/local/bin" ], "stdin": { - "src": null, "content": "", - "fileId": null, - "name": null, "max": 4194304, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stdout": { - "src": null, - "content": null, - "fileId": null, "name": "stdout", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, "stderr": { - "src": null, - "content": null, - "fileId": null, "name": "stderr", "max": 4000000000, - "symlink": null, "streamIn": false, "streamOut": false, "pipe": false }, - "cpuLimit": 10000000000, + "cpuLimit": 4000000000, "realCpuLimit": 0, - "clockLimit": 20000000000, - "memoryLimit": 524288000, + "clockLimit": 8000000000, + "memoryLimit": 4194304, "stackLimit": 0, "procLimit": 50, "cpuRateLimit": 0, @@ -1102,175 +802,259 @@ "dataSegmentLimit": false, "addressSpaceLimit": false }, - "cases": [ - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case4.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 30000000000, - "realCpuLimit": null, - "clockLimit": 60000000000, - "memoryLimit": 10485760, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case5.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - }, - { - "args": null, - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "src": "/home/tt/.config/joj/judge-msan/case6.in", - "content": null, - "fileId": null, - "name": null, - "max": 4194304, - "symlink": null, - "streamIn": false, - "streamOut": false, - "pipe": false - }, - "stdout": null, - "stderr": null, - "cpuLimit": 4000000000, - "realCpuLimit": null, - "clockLimit": 8000000000, - "memoryLimit": 4194304, - "stackLimit": null, - "procLimit": 50, - "cpuRateLimit": null, - "cpuSetLimit": null, - "copyIn": null, - "copyInCached": null, - "copyInDir": null, - "copyOut": null, - "copyOutCached": null, - "copyOutMax": null, - "copyOutDir": null, - "tty": null, - "strictMemoryLimit": null, - "dataSegmentLimit": null, - "addressSpaceLimit": null - } - ] + "cases": [] } }, "parsers": [ { - "name": "diff", + "name": "result-status", "with": { - "name": "diff", - "cases": [ - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case4.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case5.out", - "forceQuitOnDiff": true, - "alwaysHide": false, - "compareSpace": true - } - ] - }, - { - "outputs": [ - { - "score": 0, - "fileName": "stdout", - "answerPath": "/home/tt/.config/joj/judge-msan/case6.out", - "forceQuitOnDiff": true, - "alwaysHide": true, - "compareSpace": true - } - ] - } - ] + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false } }, { - "name": "dummy", + "name": "result-detail", "with": { "score": 0, "comment": "", - "forceQuitOnNotAccepted": true + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] address sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./asan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] memory sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./msan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false + } + }, + { + "name": "result-detail", + "with": { + "score": 0, + "comment": "", + "showFiles": [ + "stderr" + ], + "showExitStatus": true, + "showRuntime": true, + "showMemory": true + } + } + ] + }, + { + "name": "[run] undefined behavior sanitizer", + "executor": { + "name": "sandbox", + "with": { + "default": { + "args": [ + "./ubsan", + "-a" + ], + "env": [ + "PATH=/usr/bin:/bin:/usr/local/bin" + ], + "stdin": { + "content": "", + "max": 4194304, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stdout": { + "name": "stdout", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "stderr": { + "name": "stderr", + "max": 4000000000, + "streamIn": false, + "streamOut": false, + "pipe": false + }, + "cpuLimit": 4000000000, + "realCpuLimit": 0, + "clockLimit": 8000000000, + "memoryLimit": 4194304, + "stackLimit": 0, + "procLimit": 50, + "cpuRateLimit": 0, + "cpuSetLimit": "", + "copyIn": {}, + "copyInCached": {}, + "copyInDir": ".", + "copyOut": [], + "copyOutCached": [], + "copyOutMax": 0, + "copyOutDir": "", + "tty": false, + "strictMemoryLimit": false, + "dataSegmentLimit": false, + "addressSpaceLimit": false + }, + "cases": [] + } + }, + "parsers": [ + { + "name": "result-status", + "with": { + "score": 1, + "comment": "", + "forceQuitOnNotAccepted": false } }, { diff --git a/tests/convert/basic/task.toml b/tests/convert/basic/task.toml index b060a9e..118247d 100644 --- a/tests/convert/basic/task.toml +++ b/tests/convert/basic/task.toml @@ -1,22 +1,31 @@ -# general task configuration -task="Homework 1 exercise 2" # task name +# p2 repo config + +task="p2 m3" # task name release.deadline = 2024-10-12 23:59:00+08:00 release.stages = [ "compile" ] +[files] +immutable = [".gitignore", ".gitattributes", ".gitea/workflows/push.yaml", ".gitea/workflows/release.yaml" ] +required = [ "Changelog.md", "Readme.md" ] + +[[stages]] +name = "Abuse of strings detected" +command = "./strdetect src/" +files.import = [ "tools/strdetec" ] + +parsers = [ "result-status" ] + + [[stages]] name = "Compilation" -command = "make.sh" # eg. script running cmake commands -files.import = [ "tools/make.sh", "src/main.c", "src/task.h", "srcCMakelist.txt" ] -files.export = [ "driver", "p2", "p2-msan" ] -limit.cpu = 180 # p2 takes long to compile -limit.stderr = 128 +command = "compile" +files.import = [ "tools/compile" ] +files.export = [ "build/onecard", "build/asan", "build/ubsan", "build/msan", "build/compile_commands.json" ] -# compile parsers parsers = [ "result-detail", "dummy", "result-status" ] result-status.comment = "Congratulations! Your code compiled successfully." result-status.score = 1 -result-status.forcequit = false dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true @@ -24,29 +33,13 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "File length check" -command = "./file-length 500 400 *.c *.h" # command to run -files.import = [ "tools/file-length" ] +name = "[cq] Filelength" +command = "./file-length 400 300 *.c *.h" +files.import = [ "tools/filelength" ] parsers = [ "keyword", "dummy", "result-detail" ] -keyword.keyword = [ "max", "recommend"] # keywords caught by corresponding JOJ plugin -keyword.weight = [ 50, 20 ] # weight of each keyword -result-detail.exitstatus = true -result-detail.stderr = true -result-detail.time = false -result-detail.mem = false -result-status.comment = "Manuel Charlemagne" -result-status.score = 10000 -result-status.forcequit = true - -[[stages]] -name = "Clang-tidy checks" -command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" -limit.stdout = 65 - -parsers = [ "clangtidy", "dummy", "result-detail" ] -clangtidy.keyword = [ "codequality-no-global-variables", "codequality-no-header-guard", "readability-function-size", "readability-duplicate-include", "readability-identifier-naming", "readability-redundant", "readability-misleading-indentation", "readability-misplaced-array-index", "cppcoreguidelines-init-variables", "bugprone-suspicious-string-compare", "google-global-names-in-headers", "clang-diagnostic", "clang-analyzer", "misc performance" ] -clangtidy.weight = [10, 10, 50, 10, 5, 5, 10, 5, 5, 8, 5, 5, 5, 5] +keyword.keyword = [ "max", "recommended"] +keyword.weight = [ 20, 10 ] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stdout = true @@ -54,13 +47,28 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "Cppcheck check" -command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --quiet ./" +name = "[cq] Clang-tidy" +command = "run-clang-tidy-18 -header-filter=.* -quiet -load=/usr/local/lib/libcodequality.so -p build" +files.import = [ "projects/p2/.clang-tidy", "build/compile_commands.json" ] +limit.stdout = 65 + +parsers = [ "clangtidy", "dummy", "result-detail" ] +clangtidy.keyword = [ "codequality-unchecked-malloc-result", "codequality-no-global-variables", "codequality-no-header-guard", "codequality-no-fflush-stdin", "readability-function-size", "readability-duplicate-include", "readability-identifier-naming", "readability-redundant", "readability-misleading-indentation", "readability-misplaced-array-index", "cppcoreguidelines-init-variables", "bugprone-suspicious-string-compare", "google-global-names-in-headers", "clang-diagnostic", "clang-analyzer", "misc", "performance", "portability" ] +clangtidy.weight = [ 5, 20, 20, 20, 10, 5, 5, 5, 15, 5, 5, 5, 5, 5, 5, 5, 5, 5] +dummy.comment = "\n\n### Details\n" +result-detail.exitstatus = true +result-detail.stdout = true +result-detail.time = false +result-detail.mem = false + +[[stages]] +name = "[cq] Cppcheck" +command = "cppcheck --template='{\"file\":\"{file}\",\"line\":{line}, \"column\":{column}, \"severity\":\"{severity}\", \"message\":\"{message}\", \"id\":\"{id}\"}' --force --enable=all --suppress=missingIncludeSystem --quiet ./" limit.stderr = 65 parsers = [ "cppcheck", "dummy", "result-detail" ] cppcheck.keyword = ["error", "warning", "portability", "performance", "style"] -cppcheck.weight = [20, 10, 15, 15, 10] +cppcheck.weight = [15, 5, 5, 5, 5] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true result-detail.stderr = true @@ -68,57 +76,62 @@ result-detail.time = false result-detail.mem = false [[stages]] -name = "Cpplint check" +name = "[cq] Cpplint" command = "cpplint --linelength=120 --filter=-legal,-readability/casting,-whitespace,-runtime/printf,-runtime/threadsafe_fn,-readability/todo,-build/include_subdir,-build/header_guard --recursive --exclude=build ." limit.stdout = 65 parsers = [ "cpplint", "dummy", "result-detail" ] cpplint.keyword = [ "runtime", "readability", "build" ] -cpplint.weight = [ 10, 20, 15] +cpplint.weight = [ 5, 20, 10] dummy.comment = "\n\n### Details\n" result-detail.exitstatus = true -result-detail.stdout = true +result-detail.stderr = true result-detail.time = false result-detail.mem = false [[stages]] -name = "judge-base" -command="./driver ./mumsh" -limit.cpu = 3 -limit.mem = 75 -score = 10 +name = "[run] onecard" +group = "run" +command="./onecard -a" +files.import = [ "build/onecard" ] -parsers = ["diff", "dummy", "result-detail"] -dummy.comment = "\n\n### Details\n" +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false result-detail.exitstatus = true result-detail.stderr = true -case4.score = 15 -case4.limit.cpu = 30 -case4.limit.mem = 10 -case4.limit.stdout = 8 - -case5.score = 25 - -case8.limit.stderr = 128 - [[stages]] -name = "judge-msan" -command="./driver ./mumsh-msan" -limit.cpu = 10 # default cpu limit (in sec) for each test case -limit.mem = 500 # set default mem limit (in MB) for all OJ test cases -score = 10 -skip = ["case0", "case11"] +name = "[run] address sanitizer" +group = "run" +command="./asan -a" +files.import = [ "build/asan" ] -parsers = ["diff", "dummy", "result-detail"] -dummy.comment = "\n\n### Details\n" +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false result-detail.exitstatus = true result-detail.stderr = true -case4.score = 15 -case4.limit.cpu = 30 -case4.limit.mem = 10 +[[stages]] +name = "[run] memory sanitizer" +group = "run" +command="./msan -a" +files.import = [ "build/msan" ] -case5.diff.output.ignorespaces = false +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true -case6.diff.output.hide = true +[[stages]] +name = "[run] undefined behavior sanitizer" +command="./ubsan -a" +files.import = [ "build/ubsan" ] + +parsers = [ "result-status", "result-detail" ] +result-status.score = 1 +result-status.forcequit = false +result-detail.exitstatus = true +result-detail.stderr = true diff --git a/tests/convert/test_convert_cases.py b/tests/convert/test_convert_cases.py index c3ac6cb..1a3392a 100644 --- a/tests/convert/test_convert_cases.py +++ b/tests/convert/test_convert_cases.py @@ -3,5 +3,3 @@ from tests.convert.utils import load_case def test_basic() -> None: load_case("basic") - -test_basic() \ No newline at end of file