4
4
import glob
5
5
6
6
from sinol_make import configure_parsers
7
+ from sinol_make import util as sm_util
7
8
from sinol_make .commands .gen import Command
8
9
from sinol_make .commands .gen import gen_util
9
- from sinol_make .helpers import package_util , paths
10
+ from sinol_make .helpers import package_util , paths , cache
10
11
from tests .fixtures import *
11
12
from tests import util
12
13
@@ -47,6 +48,9 @@ def test_correct_inputs(capsys, create_package):
47
48
"""
48
49
Test `ingen` command with all unchanged inputs.
49
50
"""
51
+ task_id = package_util .get_task_id ()
52
+ correct_solution = package_util .get_correct_solution (task_id )
53
+ cache .save_compiled (correct_solution , "exe" )
50
54
simple_run ()
51
55
md5_sums = get_md5_sums (create_package )
52
56
@@ -63,6 +67,9 @@ def test_changed_inputs(capsys, create_package):
63
67
"""
64
68
Test `ingen` command with changed inputs.
65
69
"""
70
+ task_id = package_util .get_task_id ()
71
+ correct_solution = package_util .get_correct_solution (task_id )
72
+ cache .save_compiled (correct_solution , "exe" )
66
73
simple_run ()
67
74
md5_sums = get_md5_sums (create_package )
68
75
correct_md5 = md5_sums .copy ()
@@ -152,3 +159,29 @@ def test_missing_output_files(create_package):
152
159
assert os .path .exists (outs [0 ])
153
160
shutil .rmtree (paths .get_cache_path ())
154
161
os .unlink (os .path .join (package_path , "in" , ".md5sums" ))
162
+
163
+
164
+ @pytest .mark .parametrize ("create_package" , [util .get_shell_ingen_pack_path (), util .get_simple_package_path ()],
165
+ indirect = True )
166
+ def test_correct_solution_changed (create_package ):
167
+ """
168
+ Test if `.md5sums` is deleted when correct solution is changed.
169
+ """
170
+ package_path = create_package
171
+ task_id = package_util .get_task_id ()
172
+ md5sums = os .path .join (package_path , "in" , ".md5sums" )
173
+ simple_run ()
174
+ assert os .path .exists (md5sums )
175
+ outputs = {}
176
+ for output in glob .glob (os .path .join (package_path , "out" , "*.out" )):
177
+ outputs [os .path .basename (output )] = sm_util .get_file_md5 (output )
178
+
179
+ solution = package_util .get_correct_solution (task_id )
180
+ with open (os .path .join (solution ), "w" ) as f :
181
+ f .write ("int main() {}" )
182
+ cache .check_correct_solution (task_id )
183
+ assert not os .path .exists (md5sums )
184
+ simple_run ()
185
+ assert os .path .exists (md5sums )
186
+ for output in glob .glob (os .path .join (package_path , "out" , "*.out" )):
187
+ assert outputs [os .path .basename (output )] != sm_util .get_file_md5 (output )
0 commit comments