From 1f0ee639dd6c225ef1b65846b9a8d90793901d94 Mon Sep 17 00:00:00 2001 From: jon-lee Date: Thu, 27 Feb 2025 15:31:08 +0800 Subject: [PATCH] fix: pass pytest --- joj3_config_generator/main.py | 2 +- joj3_config_generator/models/task.py | 4 +- joj3_config_generator/processers/repo.py | 2 +- tests/convert/clang-tidy/task.json | 105 ----------------------- tests/convert/cppcheck/task.json | 105 ----------------------- tests/convert/cpplint/task.json | 105 ----------------------- tests/convert/diff/task.json | 105 ----------------------- tests/convert/keyword/task.json | 105 ----------------------- tests/convert_joj1/utils.py | 4 +- 9 files changed, 6 insertions(+), 531 deletions(-) diff --git a/joj3_config_generator/main.py b/joj3_config_generator/main.py index 53884c7..027a716 100644 --- a/joj3_config_generator/main.py +++ b/joj3_config_generator/main.py @@ -41,7 +41,7 @@ def convert_joj1(yaml_file: typer.FileText, toml_file: typer.FileTextWrite) -> N joj1_obj = yaml.safe_load(yaml_file.read()) joj1_model = joj1.Config(**joj1_obj) task_model = convert_joj1_conf(joj1_model) - result_dict = task_model.model_dump(by_alias=True) + result_dict = task_model.model_dump(by_alias=True, exclude_none=True) toml_file.write(rtoml.dumps(result_dict)) diff --git a/joj3_config_generator/models/task.py b/joj3_config_generator/models/task.py index 708d36e..bcc59c7 100644 --- a/joj3_config_generator/models/task.py +++ b/joj3_config_generator/models/task.py @@ -108,8 +108,8 @@ class Task(BaseModel): class Config(BaseModel): - root: Path = Path(".") - path: Path = Path("task.toml") + root: Optional[Path] = None + path: Optional[Path] = None task: Task # Task name (e.g., hw3 ex5) release: Release # Release configuration stages: List[Stage] # list of stage configurations diff --git a/joj3_config_generator/processers/repo.py b/joj3_config_generator/processers/repo.py index 06b571f..b6b74c7 100644 --- a/joj3_config_generator/processers/repo.py +++ b/joj3_config_generator/processers/repo.py @@ -122,7 +122,7 @@ def calc_sha256sum(file_path: Path) -> str: def get_hash( immutable_files: list[str], repo_conf: repo.Config ) -> str: # input should be a list - repo_path = repo_conf.path.parent + repo_path = (repo_conf.root / repo_conf.path).parent file_path = Path(f"{repo_path}/immutable_files") immutable_hash = [] immutable_files_ = [] diff --git a/tests/convert/clang-tidy/task.json b/tests/convert/clang-tidy/task.json index 8c8ed9f..5c68e1b 100644 --- a/tests/convert/clang-tidy/task.json +++ b/tests/convert/clang-tidy/task.json @@ -10,111 +10,6 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 4096 - }, - "stderr": { - "name": "stderr", - "max": 4096 - }, - "cpuLimit": 4000000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=10", - "-checkFileSumList=-checkFileNameList=" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "args": [ - "/usr/local/bin/joint-teapot", - "joj3-check-env", - "/home/tt/.config/teapot/teapot.env", - "--grading-repo-name", - "ece280-joj", - "--group-config", - "=100:24" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - } - ] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 1 - } - }, - { - "name": "debug", - "with": { - "score": 0 - } - } - ] - }, { "name": "[cq] Clang-tidy", "group": "cq", diff --git a/tests/convert/cppcheck/task.json b/tests/convert/cppcheck/task.json index dab704d..f88faff 100644 --- a/tests/convert/cppcheck/task.json +++ b/tests/convert/cppcheck/task.json @@ -10,111 +10,6 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 4096 - }, - "stderr": { - "name": "stderr", - "max": 4096 - }, - "cpuLimit": 4000000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=10", - "-checkFileSumList=-checkFileNameList=" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "args": [ - "/usr/local/bin/joint-teapot", - "joj3-check-env", - "/home/tt/.config/teapot/teapot.env", - "--grading-repo-name", - "ece280-joj", - "--group-config", - "=100:24" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - } - ] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 1 - } - }, - { - "name": "debug", - "with": { - "score": 0 - } - } - ] - }, { "name": "[cq] Cppcheck", "group": "cq", diff --git a/tests/convert/cpplint/task.json b/tests/convert/cpplint/task.json index b032a61..59fffc3 100644 --- a/tests/convert/cpplint/task.json +++ b/tests/convert/cpplint/task.json @@ -10,111 +10,6 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 4096 - }, - "stderr": { - "name": "stderr", - "max": 4096 - }, - "cpuLimit": 4000000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=10", - "-checkFileSumList=-checkFileNameList=" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "args": [ - "/usr/local/bin/joint-teapot", - "joj3-check-env", - "/home/tt/.config/teapot/teapot.env", - "--grading-repo-name", - "ece280-joj", - "--group-config", - "=100:24" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - } - ] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 1 - } - }, - { - "name": "debug", - "with": { - "score": 0 - } - } - ] - }, { "name": "[cq] Cpplint", "group": "cq", diff --git a/tests/convert/diff/task.json b/tests/convert/diff/task.json index fe010ce..d5d5773 100644 --- a/tests/convert/diff/task.json +++ b/tests/convert/diff/task.json @@ -10,111 +10,6 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 4096 - }, - "stderr": { - "name": "stderr", - "max": 4096 - }, - "cpuLimit": 4000000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=10", - "-checkFileSumList=-checkFileNameList=" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "args": [ - "/usr/local/bin/joint-teapot", - "joj3-check-env", - "/home/tt/.config/teapot/teapot.env", - "--grading-repo-name", - "ece280-joj", - "--group-config", - "=100:24" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - } - ] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 1 - } - }, - { - "name": "debug", - "with": { - "score": 0 - } - } - ] - }, { "name": "[joj] ex2-asan", "group": "joj", diff --git a/tests/convert/keyword/task.json b/tests/convert/keyword/task.json index c2e2fcb..3ba8c53 100644 --- a/tests/convert/keyword/task.json +++ b/tests/convert/keyword/task.json @@ -10,111 +10,6 @@ "sandboxToken": "", "outputPath": "/tmp/joj3_result.json", "stages": [ - { - "name": "healthcheck", - "group": "", - "executor": { - "name": "local", - "with": { - "default": { - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "stdin": { - "content": "", - "max": 419430400 - }, - "stdout": { - "name": "stdout", - "max": 4096 - }, - "stderr": { - "name": "stderr", - "max": 4096 - }, - "cpuLimit": 4000000000000, - "realCpuLimit": 0, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "stackLimit": 0, - "procLimit": 50, - "cpuRateLimit": 0, - "cpuSetLimit": "", - "copyIn": {}, - "copyInCached": {}, - "copyInDir": ".", - "copyOut": [ - "stdout", - "stderr" - ], - "copyOutCached": [], - "copyOutMax": 0, - "copyOutDir": "", - "tty": false, - "strictMemoryLimit": false, - "dataSegmentLimit": false, - "addressSpaceLimit": false - }, - "cases": [ - { - "args": [ - "/usr/local/bin/repo-health-checker", - "-root=.", - "-repoSize=10", - "-checkFileSumList=-checkFileNameList=" - ], - "env": [ - "PATH=/usr/bin:/bin:/usr/local/bin" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - }, - { - "args": [ - "/usr/local/bin/joint-teapot", - "joj3-check-env", - "/home/tt/.config/teapot/teapot.env", - "--grading-repo-name", - "ece280-joj", - "--group-config", - "=100:24" - ], - "env": [ - "LOG_FILE_PATH=/home/tt/.cache/joint-teapot-debug.log" - ], - "cpuLimit": 4000000000000, - "clockLimit": 8000000000000, - "memoryLimit": 838860800, - "procLimit": 50, - "copyOut": [ - "stdout", - "stderr" - ] - } - ] - } - }, - "parsers": [ - { - "name": "healthcheck", - "with": { - "score": 1 - } - }, - { - "name": "debug", - "with": { - "score": 0 - } - } - ] - }, { "name": "[cq] Filelength", "group": "cq", diff --git a/tests/convert_joj1/utils.py b/tests/convert_joj1/utils.py index 74aa1b5..947c5c2 100644 --- a/tests/convert_joj1/utils.py +++ b/tests/convert_joj1/utils.py @@ -18,6 +18,6 @@ def read_convert_joj1_files(case_name: str) -> Tuple[joj1.Config, Dict[str, Any] def load_case(case_name: str) -> None: - joj1, expected_result = read_convert_joj1_files(case_name) - result = convert_joj1(joj1).model_dump(by_alias=True, exclude_none=True) + joj1_, expected_result = read_convert_joj1_files(case_name) + result = convert_joj1(joj1_).model_dump(by_alias=True, exclude_none=True) assert result == expected_result