fix: specified case with base dir
All checks were successful
build / build (push) Successful in 2m0s
build / trigger-build-image (push) Successful in 11s

This commit is contained in:
张泊明518370910136 2025-09-26 01:26:42 -07:00
parent 04839aecbd
commit 09f15f21ad
GPG Key ID: D47306D7062CDA9D
7 changed files with 224 additions and 8 deletions

View File

@ -197,16 +197,19 @@ def fix_diff(
task_path: Path,
) -> None:
base_dir = JOJ3_CONFIG_ROOT / task_path.parent
case_base_dir = Path(task_stage.base_case_dir)
# cases not specified in the toml config (auto-detected)
unspecified_cases = get_unspecified_cases(
task_root, task_path, Path(task_stage.base_case_dir), task_stage.cases
task_root, task_path, case_base_dir, task_stage.cases
)
# cases specified in toml config but not skipped
specified_cases = [(case, task_stage.cases[case]) for case in task_stage.cases]
stage_cases = []
parser_cases = []
for case_name, case in specified_cases:
stdin, stdout = get_stdin_stdout(task_root, task_path, case_name, case)
stdin, stdout = get_stdin_stdout(
task_root, task_path, case_base_dir, case_name, case
)
if stdout is None:
logger.warning(
f"In file {task_root / task_path}, "
@ -281,10 +284,12 @@ def fix_diff(
def get_unspecified_cases(
task_root: Path, task_path: Path, base_dir: Path, cases: Dict[str, task.Case]
task_root: Path, task_path: Path, case_base_dir: Path, cases: Dict[str, task.Case]
) -> List[str]:
testcases = set()
for testcases_path in ((task_root / task_path).parent / base_dir).glob("**/*.in"):
for testcases_path in ((task_root / task_path).parent / case_base_dir).glob(
"**/*.in"
):
if not testcases_path.with_suffix(".out").exists():
logger.warning(
f"In file {task_root / task_path}, "
@ -311,9 +316,13 @@ def get_unspecified_cases(
def get_stdin_stdout(
task_root: Path, task_path: Path, case_name: str, case: task.Case
task_root: Path,
task_path: Path,
case_base_dir: Path,
case_name: str,
case: task.Case,
) -> Tuple[result.Stdin, Optional[str]]:
base_dir = (task_root / task_path).parent
base_dir = (task_root / task_path).parent / case_base_dir
stdin: result.Stdin = result.MemoryFile(content="")
stdout = None
for case_stdout_path in base_dir.glob("**/*.out"):

View File

@ -330,7 +330,7 @@
]
},
{
"name": "[joj] ex2-asan base dir",
"name": "[joj] ex2-asan base dir task1",
"groups": [
"joj"
],
@ -390,6 +390,11 @@
"src": "/home/tt/.config/joj/diff/task1/case5.in"
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task1/case9.in"
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task1/case4.in"
@ -429,6 +434,21 @@
}
]
},
{
"outputs": [
{
"score": 99999,
"filename": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task1/case9.out",
"compareSpace": false,
"alwaysHide": false,
"forceQuitOnDiff": false,
"maxDiffLength": 2048,
"maxDiffLines": 50,
"hideCommonPrefix": false
}
]
},
{
"outputs": [
{
@ -497,6 +517,175 @@
}
}
]
},
{
"name": "[joj] ex2-asan base dir task2",
"groups": [
"joj"
],
"executor": {
"name": "sandbox",
"with": {
"default": {
"args": [
"./h7/build/ex2-asan",
"-a"
],
"env": [
"PATH=/usr/bin:/bin:/usr/local/bin"
],
"stdin": {
"content": ""
},
"stdout": {
"name": "stdout",
"max": 10485760,
"pipe": true
},
"stderr": {
"name": "stderr",
"max": 10485760,
"pipe": true
},
"cpuLimit": 3000000000,
"clockLimit": 6000000000,
"memoryLimit": 10485760,
"stackLimit": 0,
"procLimit": 50,
"cpuRateLimit": 0,
"cpuSetLimit": "",
"copyIn": {
"h7/build/ex2-asan": {
"src": "/home/tt/.config/joj/h7/build/ex2-asan"
}
},
"copyInCached": {},
"copyInDir": ".",
"copyOut": [
"stdout",
"stderr"
],
"copyOutCached": [],
"copyOutMax": 0,
"copyOutDir": "",
"tty": false,
"strictMemoryLimit": false,
"dataSegmentLimit": false,
"addressSpaceLimit": false
},
"cases": [
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task2/case9.in"
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task2/case6.in"
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task2/case7.in"
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task2/case8.in"
}
}
]
}
},
"parsers": [
{
"name": "diff",
"with": {
"name": "diff",
"cases": [
{
"outputs": [
{
"score": 99999,
"filename": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task2/case9.out",
"compareSpace": false,
"alwaysHide": false,
"forceQuitOnDiff": false,
"maxDiffLength": 2048,
"maxDiffLines": 50,
"hideCommonPrefix": false
}
]
},
{
"outputs": [
{
"score": 100,
"filename": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task2/case6.out",
"compareSpace": false,
"alwaysHide": false,
"forceQuitOnDiff": false,
"maxDiffLength": 2048,
"maxDiffLines": 50,
"hideCommonPrefix": false
}
]
},
{
"outputs": [
{
"score": 100,
"filename": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task2/case7.out",
"compareSpace": false,
"alwaysHide": false,
"forceQuitOnDiff": false,
"maxDiffLength": 2048,
"maxDiffLines": 50,
"hideCommonPrefix": false
}
]
},
{
"outputs": [
{
"score": 100,
"filename": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task2/case8.out",
"compareSpace": false,
"alwaysHide": false,
"forceQuitOnDiff": false,
"maxDiffLength": 2048,
"maxDiffLines": 50,
"hideCommonPrefix": false
}
]
}
]
}
},
{
"name": "result-detail",
"with": {
"score": 0,
"comment": "",
"showExxecutorStatus": true,
"showExitStatus": true,
"showError": false,
"showTime": true,
"showMemory": true,
"showRuntime": true,
"showProcPeak": false,
"showFiles": [
"stderr"
],
"filesInCodeBlock": true,
"maxFileLength": 2048
}
}
]
}
],
"preStages": [],

View File

@ -43,7 +43,7 @@ case5.diff.score = 2590
[[stages]]
name = "[joj] ex2-asan base dir"
name = "[joj] ex2-asan base dir task1"
command = "./h7/build/ex2-asan -a"
base-case-dir = "task1"
files.import = ["h7/build/ex2-asan"]
@ -59,3 +59,21 @@ result-detail.stderr = true
diff.score = 100
case5.diff.score = 2590
case9.diff.score = 99999
[[stages]]
name = "[joj] ex2-asan base dir task2"
command = "./h7/build/ex2-asan -a"
base-case-dir = "task2"
files.import = ["h7/build/ex2-asan"]
limit.cpu = "3s"
limit.mem = "10m"
limit.stdout = "10m"
limit.stderr = "10m"
parsers = ["diff", "result-detail"]
result-detail.exit-status = true
result-detail.stderr = true
diff.score = 100
case9.diff.score = 99999

View File

View File

View File

View File