1212from task_maker .config import Config
1313from task_maker .uis .ioi_finish_ui import IOIFinishUI
1414from task_maker .uis .ioi_curses_ui import IOICursesUI
15- from task_maker .uis .ioi import IOIUIInterface
15+ from task_maker .uis .ioi import IOIUIInterface , TestcaseGenerationStatus
1616from task_maker .formats import ScoreMode , Subtask , TestCase , Task , \
1717 list_files , Validator , Generator , get_options , VALIDATION_INPUT_NAME , \
1818 gen_grader_map , get_write_input_file , get_write_output_file , TaskType , \
@@ -100,8 +100,8 @@ def create_subtask(subtask_num: int, testcases: Dict[int, TestCase],
100100 current_testcases = {}
101101 current_score = float (line [4 :].strip ())
102102 continue
103- if line .startswith ("#COPY: " ):
104- testcase = TestCase (None , validator , [], [], line [7 :].strip (),
103+ if line .startswith ("#COPY:" ):
104+ testcase = TestCase (None , validator , [], [], line [6 :].strip (),
105105 None , get_write_input_file (testcase_num ),
106106 get_write_output_file (testcase_num ))
107107 else :
@@ -119,6 +119,8 @@ def create_subtask(subtask_num: int, testcases: Dict[int, TestCase],
119119 current_testcases [testcase_num ] = testcase
120120 testcase_num += 1
121121
122+ if subtask_num == - 1 :
123+ subtask_num = 0
122124 create_subtask (subtask_num , current_testcases , current_score )
123125 # Hack for when subtasks are not specified.
124126 if len (subtasks ) == 1 and subtasks [0 ].max_score == 0 :
@@ -160,8 +162,8 @@ def create_task_from_yaml(data: Dict[str, Any]) -> Task:
160162 output_file = get_options (data , ["outfile" ], "output.txt" )
161163
162164 task = Task (name , title , {}, None , [], None , time_limit , memory_limit ,
163- input_file if input_file else "" , output_file
164- if output_file else "" , TaskType .Batch )
165+ input_file if input_file else "" ,
166+ output_file if output_file else "" , TaskType .Batch )
165167 return task
166168
167169
@@ -221,12 +223,12 @@ def create_task(config: Config):
221223
222224 if checker is not None :
223225 target = os .path .join (os .path .dirname (checker ), "checker" )
224- task .checker = SourceFile .from_file (checker , task .name , True ,
225- target , Arch .DEFAULT , {})
226+ task .checker = SourceFile .from_file (checker , task .name , True , target ,
227+ Arch .DEFAULT , {})
226228 if manager is not None :
227229 target = os .path .join (os .path .dirname (checker ), "manager" )
228- task .checker = SourceFile .from_file (manager , task .name , True ,
229- target , Arch .DEFAULT , {})
230+ task .checker = SourceFile .from_file (manager , task .name , True , target ,
231+ Arch .DEFAULT , {})
230232
231233 sols = [] # type: List[Solution]
232234 for solution in solutions :
@@ -287,9 +289,10 @@ def evaluate_task(frontend: Frontend, task: Task, solutions: List[Solution],
287289 return ui_interface
288290
289291
290- def generate_inputs (frontend , task : Task , interface : IOIUIInterface ,
291- config : Config ) -> (Dict [Tuple [int , int ], File ], Dict [
292- Tuple [int , int ], File ], Dict [Tuple [int , int ], File ]):
292+ def generate_inputs (
293+ frontend , task : Task , interface : IOIUIInterface , config : Config
294+ ) -> (Dict [Tuple [int , int ], File ], Dict [Tuple [int , int ], File ],
295+ Dict [Tuple [int , int ], File ]):
293296 def add_non_solution (source : SourceFile ):
294297 if not source .prepared :
295298 source .prepare (frontend , config )
@@ -307,19 +310,27 @@ def add_non_solution(source: SourceFile):
307310
308311 # static input file
309312 if testcase .input_file :
310- inputs [testcase_id ] = frontend .provideFile (
311- testcase .input_file , "Static input %d" % tc_num , False )
312- if testcase .validator :
313- val = testcase .validator .source_file .execute (
314- frontend , "Validation of input %d" % tc_num ,
315- testcase .validator .get_args (testcase , subtask , tc_num ,
316- st_num + 1 ))
317- if config .cache == CacheMode .NOTHING :
318- val .disableCache ()
319- val .addInput (VALIDATION_INPUT_NAME , inputs [testcase_id ])
320- validations [testcase_id ] = val .stdout (False )
321-
322- interface .add_validation (st_num , tc_num , val )
313+ try :
314+ inputs [testcase_id ] = frontend .provideFile (
315+ testcase .input_file , "Static input %d" % tc_num , False )
316+
317+ if testcase .validator :
318+ val = testcase .validator .source_file .execute (
319+ frontend , "Validation of input %d" % tc_num ,
320+ testcase .validator .get_args (
321+ testcase , subtask , tc_num , st_num + 1 ))
322+ if config .cache == CacheMode .NOTHING :
323+ val .disableCache ()
324+ val .addInput (VALIDATION_INPUT_NAME ,
325+ inputs [testcase_id ])
326+ validations [testcase_id ] = val .stdout (False )
327+
328+ interface .add_validation (st_num , tc_num , val )
329+ except RuntimeError as ex :
330+ interface .add_error (str (ex ))
331+ interface .subtasks [st_num ][
332+ tc_num ].status = TestcaseGenerationStatus .FAILURE
333+ continue
323334 # generate input file
324335 else :
325336 add_non_solution (testcase .generator .source_file )
0 commit comments