@@ -217,7 +217,7 @@ def run(self, bar, cwd):
217
217
bar .log ("stderr" , result .err )
218
218
return result
219
219
220
- def run_interaction (self , bar , cwd , t ):
220
+ def generate_interaction (self , bar , cwd , t ):
221
221
in_path = cwd / "testcase.in"
222
222
interaction_path = cwd / "testcase.interaction"
223
223
interaction_path .unlink (missing_ok = True )
@@ -787,6 +787,7 @@ def init_meta():
787
787
"generated_extensions" : [],
788
788
"input_validator_hashes" : dict (),
789
789
"solution_hash" : dict (),
790
+ "interactor_hash" : dict (),
790
791
"ans_out_validator_hashes" : dict (),
791
792
"visualizer_hash" : dict (),
792
793
}
@@ -924,7 +925,7 @@ def generate_from_rule():
924
925
assert t ._has_required_in (infile ), f"Failed to generate in file: { infile .name } "
925
926
return True
926
927
927
- def generate_from_solution (testcase : Testcase ):
928
+ def generate_from_solution (testcase : Testcase , bar : ProgressBar ):
928
929
nonlocal meta_yaml
929
930
930
931
if testcase .root in [* config .INVALID_CASE_DIRECTORIES , "valid_output" ]:
@@ -943,11 +944,16 @@ def generate_from_solution(testcase: Testcase):
943
944
"solution" : None ,
944
945
}
945
946
946
- def needed (ext ):
947
+ def needed (ext , interactor_hash = None ):
947
948
if ext in meta_yaml ["generated_extensions" ]:
948
949
return False
949
950
if not infile .with_suffix (ext ).is_file ():
950
951
return True
952
+ if (
953
+ interactor_hash is not None
954
+ and meta_yaml .get ("interactor_hash" ) != interactor_hash
955
+ ):
956
+ return True
951
957
return meta_yaml .get ("solution_hash" ) != solution_hash
952
958
953
959
used_solution = False
@@ -959,19 +965,21 @@ def needed(ext):
959
965
ansfile .write_text ("" )
960
966
changed_ans = True
961
967
# For interactive/multi-pass problems, run the solution and generate a .interaction if necessary.
962
- if (
963
- (problem .interactive or problem .multi_pass )
964
- and t .config .solution
965
- and (testcase .root == "sample" or config .args .interaction )
966
- and needed (".interaction" )
967
- and not any (
968
- infile .with_suffix (ext ).is_file ()
969
- for ext in [".out" , ".in.statement" , ".ans.statement" ]
970
- )
971
- ):
972
- if not t .config .solution .run_interaction (bar , cwd , t ):
973
- return False
974
- used_solution = True
968
+ if problem .interactive or problem .multi_pass :
969
+ interactor_hash = testcase .validator_hashes (validate .OutputValidator , bar )
970
+ if (
971
+ t .config .solution
972
+ and (testcase .root == "sample" or config .args .interaction )
973
+ and needed (".interaction" , interactor_hash )
974
+ and not any (
975
+ infile .with_suffix (ext ).is_file ()
976
+ for ext in [".out" , ".in.statement" , ".ans.statement" ]
977
+ )
978
+ ):
979
+ if not t .config .solution .generate_interaction (bar , cwd , t ):
980
+ return False
981
+ used_solution = True
982
+ meta_yaml ["interactor_hash" ] = interactor_hash
975
983
else :
976
984
# Generate a .ans if not already generated by earlier steps.
977
985
if needed (".ans" ):
@@ -1212,7 +1220,7 @@ def add_testdata_to_cache():
1212
1220
return
1213
1221
1214
1222
# Step 4: generate .ans and .interaction if needed
1215
- if not generate_from_solution (testcase ):
1223
+ if not generate_from_solution (testcase , bar ):
1216
1224
return
1217
1225
1218
1226
# Step 5: validate .ans (and .out if it exists)
0 commit comments