2626import pytest
2727
2828import util
29- from util import partdiff_params_tuple
29+ from util import ReferenceSource , partdiff_params_tuple
3030
3131
3232def shlex_list_str (value : str ) -> list [str ]:
@@ -41,16 +41,16 @@ def shlex_list_str(value: str) -> list[str]:
4141 return shlex .split (value )
4242
4343
44- def reference_source_param (value : str ) -> util . ReferenceSource :
44+ def reference_source_param (value : str ) -> ReferenceSource :
4545 """Parse a ReferenceSource from str.
4646
4747 Args:
4848 value (str): The str to parse.
4949
5050 Returns:
51- util. ReferenceSource: The parsed ReferenceSource.
51+ ReferenceSource: The parsed ReferenceSource.
5252 """
53- return util . ReferenceSource (value )
53+ return ReferenceSource (value )
5454
5555
5656REGEX_NUM_LIST = re .compile (r"^(?:\d+(?:-\d+)?)(?:,\d+(?:-\d+)?)*$" )
@@ -217,8 +217,8 @@ def pytest_addoption(parser: pytest.Parser) -> None:
217217 "auto == try cache and fall back to impl)."
218218 ),
219219 type = reference_source_param ,
220- default = util . ReferenceSource .cache ,
221- choices = util . ReferenceSource ,
220+ default = ReferenceSource .cache ,
221+ choices = ReferenceSource ,
222222 )
223223 custom_options .addoption (
224224 "--num-threads" ,
@@ -315,6 +315,16 @@ def pytest_configure(config: pytest.Config) -> None:
315315 """
316316 See https://docs.pytest.org/en/7.1.x/reference/reference.html#pytest.hookspec.pytest_configure
317317 """
318+ if config .getoption ("reference_source" ) in (
319+ ReferenceSource .auto ,
320+ ReferenceSource .impl ,
321+ ):
322+ util .ensure_reference_implementation_exists ()
323+
324+ util .check_executable_exists (
325+ config .getoption ("executable" ), config .getoption ("cwd" )
326+ )
327+
318328 if config .getoption ("valgrind" ):
319329 if shutil .which ("valgrind" ) is None :
320330 raise RuntimeError ("Passed --valgrind, but valgrind could not be found." )
0 commit comments