diff --git a/p2d/parse_polygon_package.py b/p2d/parse_polygon_package.py index 850244d..af5dca2 100644 --- a/p2d/parse_polygon_package.py +++ b/p2d/parse_polygon_package.py @@ -4,6 +4,7 @@ import pathlib import re import sys +from filecmp import cmp import xml.etree.ElementTree from p2d._version import __version__ @@ -153,14 +154,16 @@ def pol_path(*path): input_format = testset.find('input-path-pattern').text output_format = testset.find('answer-path-pattern').text - # Fetch samples from statements directory (for custum input/output) + # Fetch samples from statements directory (for custum output) sample_input_format = input_format.replace('tests/', os.path.join('statements', 'english') + '/example.') sample_output_format = output_format.replace('tests/', os.path.join('statements', 'english') + '/example.') for test in testset.iter('test'): + if 'sample' in test.attrib and not cmp(pol_path(input_format % local_id), pol_path(sample_input_format % local_id)): + raise RuntimeError('Custom inputs are not supported.') # Becase DomJudge evaluates the same sample inputs that are provided to contestants. t = { 'num': test_id, - 'in': pol_path(sample_input_format % local_id) if 'sample' in test.attrib else pol_path(input_format % local_id), + 'in': pol_path(input_format % local_id), 'out': pol_path(sample_output_format % local_id) if 'sample' in test.attrib else pol_path(output_format % local_id), 'is_sample': 'sample' in test.attrib }