Skip to content

Commit

Permalink
fix: dependency tree testcases filename error
Browse files Browse the repository at this point in the history
We rename testcase filename using a counter. However, the dependency test case filenames did not follow the counter.
Currently, TOJ no longer uses a number counter to read test cases, so we can simply use the filenames
  • Loading branch information
tobiichi3227 committed Oct 24, 2024
1 parent 2ac9776 commit 4929e78
Showing 1 changed file with 19 additions and 28 deletions.
47 changes: 19 additions & 28 deletions cf2toj.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,52 +91,43 @@ async def main():

tasks_group[group_name] = {
'weight': group_points,
'remap': [],
'data': [],
'dependencies': dependencies,
}
else:
tasks_group[0] = {
'weight': 0,
'remap': [],
'data': [],
'dependencies': [],
}

for idx, test in enumerate(root.findall("./judging/testset/tests/")):
format_str = "{:02}"
for idx, test in enumerate(root.findall("./judging/testset/tests/"), start=1):
g = test.attrib.get('group', 0)

tasks_group[g]['remap'].append(idx + 1)
tasks_group[g]['data'].append(str(idx))

if not groups_enabled:
tasks_group[0]['weight'] = 100
copyfile(
(inputpath, 'tests', format_str.format(idx)),
(tmp_outputpath, 'res/testdata', "{}.in".format(idx)),
)

copyfile(
(inputpath, 'tests', format_str.format(idx) + ".a"),
(tmp_outputpath, 'res/testdata', "{}.out".format(idx)),
)

format_str = "{:02}"
if not groups_enabled:
tasks_group[0]['weight'] = 100

dst = 1
for _, g in tasks_group.items():
g['data'] = []
for src in g['remap']:
copyfile(
(inputpath, 'tests', format_str.format(src)),
(tmp_outputpath, 'res/testdata', "{}.in".format(dst)),
)

copyfile(
(inputpath, 'tests', format_str.format(src) + ".a"),
(tmp_outputpath, 'res/testdata', "{}.out".format(dst)),
)
g['data'].append(dst)
dst += 1

write_group = g.copy()
if args.enable_dependency:
for depend_group in g['dependencies']:
g['data'].extend(tasks_group[depend_group]['remap'])
write_group['data'].extend(tasks_group[depend_group]['data'])

dep = g.pop('dependencies')
remap = g.pop('remap')
conf['test'].append(g.copy())
g['dependencies'] = dep
g['remap'] = remap
write_group.pop('dependencies')
conf['test'].append(write_group)

logging.info('Creating config file')
with open(os.path.join(tmp_outputpath, 'conf.json'), 'w', encoding='utf-8') as conffile:
Expand Down

0 comments on commit 4929e78

Please sign in to comment.