feat: stages.base-case-dir
All checks were successful
build / build (push) Successful in 2m11s
build / trigger-build-image (push) Successful in 8s

This commit is contained in:
张泊明518370910136 2025-09-24 21:41:53 -07:00
parent 046a553b56
commit 04839aecbd
GPG Key ID: D47306D7062CDA9D
5 changed files with 201 additions and 6 deletions

View File

@ -192,6 +192,9 @@ class Case(StrictBaseModel):
class Stage(Case):
name: str = "" # stage name
groups: List[str] = [] # list of groups
base_case_dir: str = Field(
".", validation_alias=AliasChoices("base-case-dir", "base_case_dir")
) # base directory for finding cases
parsers: List[Parser] = [] # list of parsers
dummy: ParserDummy = ParserDummy()

View File

@ -198,7 +198,9 @@ def fix_diff(
) -> None:
base_dir = JOJ3_CONFIG_ROOT / task_path.parent
# cases not specified in the toml config (auto-detected)
unspecified_cases = get_unspecified_cases(task_root, task_path, task_stage.cases)
unspecified_cases = get_unspecified_cases(
task_root, task_path, Path(task_stage.base_case_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 = []
@ -279,10 +281,10 @@ def fix_diff(
def get_unspecified_cases(
task_root: Path, task_path: Path, cases: Dict[str, task.Case]
task_root: Path, task_path: Path, base_dir: Path, cases: Dict[str, task.Case]
) -> List[str]:
testcases = set()
for testcases_path in (task_root / task_path).parent.glob("**/*.in"):
for testcases_path in ((task_root / task_path).parent / base_dir).glob("**/*.in"):
if not testcases_path.with_suffix(".out").exists():
logger.warning(
f"In file {task_root / task_path}, "

View File

@ -328,6 +328,175 @@
}
}
]
},
{
"name": "[joj] ex2-asan base dir",
"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/task1/case5.in"
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task1/case4.in"
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task1/subtask1/case10.in"
}
},
{
"stdin": {
"src": "/home/tt/.config/joj/diff/task1/subtask1/case11.in"
}
}
]
}
},
"parsers": [
{
"name": "diff",
"with": {
"name": "diff",
"cases": [
{
"outputs": [
{
"score": 2590,
"filename": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task1/case5.out",
"compareSpace": false,
"alwaysHide": false,
"forceQuitOnDiff": false,
"maxDiffLength": 2048,
"maxDiffLines": 50,
"hideCommonPrefix": false
}
]
},
{
"outputs": [
{
"score": 100,
"filename": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task1/case4.out",
"compareSpace": false,
"alwaysHide": false,
"forceQuitOnDiff": false,
"maxDiffLength": 2048,
"maxDiffLines": 50,
"hideCommonPrefix": false
}
]
},
{
"outputs": [
{
"score": 100,
"filename": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task1/subtask1/case10.out",
"compareSpace": false,
"alwaysHide": false,
"forceQuitOnDiff": false,
"maxDiffLength": 2048,
"maxDiffLines": 50,
"hideCommonPrefix": false
}
]
},
{
"outputs": [
{
"score": 100,
"filename": "stdout",
"answerPath": "/home/tt/.config/joj/diff/task1/subtask1/case11.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

@ -6,14 +6,14 @@ time.begin = 2024-12-29 23:59:59+08:00
[[stages]]
name = "[joj] ex2-asan"
command="./h7/build/ex2-asan -a"
files.import = [ "h7/build/ex2-asan" ]
command = "./h7/build/ex2-asan -a"
files.import = ["h7/build/ex2-asan"]
limit.cpu = "3s"
limit.mem = "10m"
limit.stdout = "10m"
limit.stderr = "10m"
parsers = [ "diff", "result-detail" ]
parsers = ["diff", "result-detail"]
result-detail.exit-status = true
result-detail.stderr = true
@ -40,3 +40,22 @@ case11.diff.score = 92321
case10.diff.score = 823131
case5.diff.score = 2590
[[stages]]
name = "[joj] ex2-asan base dir"
command = "./h7/build/ex2-asan -a"
base-case-dir = "task1"
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
case5.diff.score = 2590

View File

@ -35,6 +35,8 @@ groups.time-period-hour = [24, 1]
name = "Generate yes.txt [no]"
# you can also use this fields to override the above groups
groups = ["run", "no"]
# default dir to automatically searching for cases
base-case-dir = "."
# ===================================================
# ========== executor related config start ==========