@@ -46,18 +46,17 @@ def _get_statement_path():
46
46
47
47
48
48
def _get_statement_tex ():
49
- return list_files (
50
- [ "statement/*.tex" , "testo/*.tex" ], valid_extensions = [".tex" ])
49
+ return list_files ([ "statement/*.tex" , "testo/*.tex" ],
50
+ valid_extensions = [".tex" ])
51
51
52
52
53
53
def _check_git_has_file (path : str ) -> Optional [bool ]:
54
54
# git is not installed
55
55
if not find_executable ("git" ):
56
56
return None
57
- proc = subprocess .run (
58
- ["git" , "ls-files" , "--" , path ],
59
- stderr = subprocess .DEVNULL ,
60
- stdout = subprocess .PIPE )
57
+ proc = subprocess .run (["git" , "ls-files" , "--" , path ],
58
+ stderr = subprocess .DEVNULL ,
59
+ stdout = subprocess .PIPE )
61
60
# this is not a git repository
62
61
if proc .returncode != 0 :
63
62
return None
@@ -142,8 +141,8 @@ def get_stderr(stderr):
142
141
interface .printer .text (log_prefix + "STDERR\n " + stderr + "\n " )
143
142
144
143
execution .notifyStart (notify_start )
145
- execution .getResult (get_result , skipped )
146
144
execution .stderr (False ).getContentsAsString (get_stderr )
145
+ execution .getResult (get_result , skipped )
147
146
148
147
149
148
def _setup_checker_callback (interface : IOIUIInterface , checking : Execution ,
@@ -185,8 +184,8 @@ def get_stdout(stdout):
185
184
interface .add_warning (description + " does not score any points" )
186
185
187
186
checking .notifyStart (notify_start )
188
- checking .getResult (get_result , skipped )
189
187
checking .stdout (False ).getContentsAsString (get_stdout )
188
+ checking .getResult (get_result , skipped )
190
189
191
190
192
191
def check_att_folder (task : IOITask , solutions : List [Solution ],
@@ -254,20 +253,24 @@ def check_sample_cases(task: IOITask, frontend: Frontend, config: Config,
254
253
Check if the sample cases in the statement are valid and the output is
255
254
correct
256
255
"""
257
- inputs = list_files (
258
- [
259
- "statement/input*.txt" , "statement/{}.input*.txt" .format (
260
- task .name ), "testo/input*.txt" , "testo/{}.input*.txt" .format (
261
- task .name )
262
- ],
263
- valid_extensions = [".txt" ])
264
- outputs = list_files (
265
- [
266
- "statement/output*.txt" , "statement/{}.output*.txt" .format (
267
- task .name ), "testo/output*.txt" , "testo/{}.output*.txt" .format (
268
- task .name )
269
- ],
270
- valid_extensions = [".txt" ])
256
+ # Communication tasks does not have output files
257
+ if task .task_type != TaskType .Batch :
258
+ return
259
+
260
+ # without official solution we cannot solve the input files
261
+ if not task .official_solution :
262
+ return
263
+
264
+ inputs = list_files ([
265
+ "statement/input*.txt" , "statement/{}.input*.txt" .format (task .name ),
266
+ "testo/input*.txt" , "testo/{}.input*.txt" .format (task .name )
267
+ ],
268
+ valid_extensions = [".txt" ])
269
+ outputs = list_files ([
270
+ "statement/output*.txt" , "statement/{}.output*.txt" .format (task .name ),
271
+ "testo/output*.txt" , "testo/{}.output*.txt" .format (task .name )
272
+ ],
273
+ valid_extensions = [".txt" ])
271
274
num_to_input = dict () # type: Dict[int, str]
272
275
num_to_output = dict () # type: Dict[int, str]
273
276
num_to_input_file = dict () # type: Dict[int, File]
@@ -282,11 +285,11 @@ def check_sample_cases(task: IOITask, frontend: Frontend, config: Config,
282
285
continue
283
286
sample_num = int (match .group (1 ))
284
287
num_to_input [sample_num ] = infile
285
- # skip the validations if there is no default validator
286
- if not task .default_val :
287
- break
288
288
num_to_input_file [sample_num ] = frontend .provideFile (
289
289
infile , "Sample input {}" .format (infile ), False )
290
+ # skip the validation if there is no default validator
291
+ if not task .default_val :
292
+ continue
290
293
validation = task .default_val .source_file .execute (
291
294
frontend , "Validation of sample input {}" .format (infile ),
292
295
[VALIDATION_INPUT_NAME , "0" ])
@@ -299,9 +302,13 @@ def check_sample_cases(task: IOITask, frontend: Frontend, config: Config,
299
302
interface , validation ,
300
303
"Validation of sample input {}" .format (infile ))
301
304
302
- # Communication tasks does not have output files
303
- if task .task_type != TaskType .Batch :
304
- return
305
+ # if the output files were not yet generated (e.g. when they are just
306
+ # copied), the solution is not prepared
307
+ if not task .official_solution .prepared :
308
+ task .official_solution .prepare (frontend , config )
309
+ if task .official_solution .language .need_compilation :
310
+ # TODO at some point use a centralized system to run the files
311
+ task .official_solution .compilation .getResult (lambda res : res )
305
312
306
313
for outfile in outputs :
307
314
match = re .match (r".*output(\d+).txt" , outfile )
@@ -314,14 +321,14 @@ def check_sample_cases(task: IOITask, frontend: Frontend, config: Config,
314
321
num_to_output [sample_num ] = outfile
315
322
num_to_output_file [sample_num ] = frontend .provideFile (
316
323
outfile , "Sample output {}" .format (outfile ), False )
317
- # without official solution we cannot solve the input
318
- if not task .official_solution :
319
- break
320
324
solving = task .official_solution .execute (
321
325
frontend , "Solving sample output {}" .format (outfile ), [])
322
326
if config .cache != CacheMode .ALL :
323
327
solving .disableCache ()
324
- solving .addInput ("wait_for_validation" , num_to_validation [sample_num ])
328
+ # if the validator is not present we don't wait for it
329
+ if sample_num in num_to_validation :
330
+ solving .addInput ("wait_for_validation" ,
331
+ num_to_validation [sample_num ])
325
332
if task .input_file :
326
333
solving .addInput (task .input_file , num_to_input_file [sample_num ])
327
334
else :
@@ -397,7 +404,7 @@ def sanity_pre_checks(task: IOITask, solutions: List[Solution],
397
404
check_att_folder (task , solutions , interface )
398
405
check_sol_folder (solutions , interface )
399
406
check_statement (task , interface )
400
- # check_sample_cases(task, frontend, config, interface)
407
+ check_sample_cases (task , frontend , config , interface )
401
408
check_symlinks (interface )
402
409
403
410
0 commit comments