File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed
Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change 22import subprocess
33import re
44import util
5+ from pathlib import Path
6+ import os
7+
8+ REFERENCE_IMPLEMENTATION_DIR = Path .cwd () / "reference_implementation"
9+ REFERENCE_IMPLEMENTATION_EXEC = REFERENCE_IMPLEMENTATION_DIR / "partdiff"
10+
11+
12+ def ensure_reference_implementation_exists ():
13+ def is_executable ():
14+ executable = REFERENCE_IMPLEMENTATION_EXEC
15+ return executable .exists () and os .access (executable , os .X_OK )
16+
17+ if is_executable ():
18+ return
19+ subprocess .check_output (["make" , "-C" , REFERENCE_IMPLEMENTATION_DIR ])
20+ assert is_executable ()
521
622
723def get_reference_output (partdiff_params , reference_output_data ):
8- return reference_output_data [partdiff_params ]
24+ if partdiff_params in reference_output_data :
25+ return reference_output_data [partdiff_params ]
26+ ensure_reference_implementation_exists ()
27+ command_line = [REFERENCE_IMPLEMENTATION_EXEC ] + list (partdiff_params )
28+ return subprocess .check_output (command_line ).decode ("utf-8" )
929
1030
1131def get_actual_output (partdiff_params , partdiff_executable , use_valgrind ):
1232 command_line = partdiff_executable + list (partdiff_params )
1333 if use_valgrind :
1434 command_line = ["valgrind" , "--leak-check=full" ] + command_line
15- actual_output = subprocess .check_output (command_line ).decode ("utf-8" )
16- return actual_output
35+ return subprocess .check_output (command_line ).decode ("utf-8" )
1736
1837
1938def test_partdiff_parametrized (pytestconfig , reference_output_data , test_id ):
You can’t perform that action at this time.
0 commit comments