tests: allow pytests to run in out-of-tree builds
Some of the files it needs are in the build directory but the code did not make a distinction. Closes #15257
This commit is contained in:
parent
79809ffe1e
commit
a3601cf571
@ -72,7 +72,6 @@ function(add_pytest _targetname _test_flags)
|
|||||||
endif()
|
endif()
|
||||||
string(REPLACE " " ";" _test_flags_list "${_test_flags}")
|
string(REPLACE " " ";" _test_flags_list "${_test_flags}")
|
||||||
add_custom_target(${_targetname}
|
add_custom_target(${_targetname}
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
|
||||||
COMMAND pytest ${_test_flags_list} "${CMAKE_CURRENT_SOURCE_DIR}/http"
|
COMMAND pytest ${_test_flags_list} "${CMAKE_CURRENT_SOURCE_DIR}/http"
|
||||||
DEPENDS "${_depends}"
|
DEPENDS "${_depends}"
|
||||||
VERBATIM USES_TERMINAL
|
VERBATIM USES_TERMINAL
|
||||||
|
|||||||
@ -44,7 +44,7 @@ class LocalClient:
|
|||||||
timeout: Optional[float] = None,
|
timeout: Optional[float] = None,
|
||||||
run_env: Optional[Dict[str,str]] = None):
|
run_env: Optional[Dict[str,str]] = None):
|
||||||
self.name = name
|
self.name = name
|
||||||
self.path = os.path.join(env.project_dir, f'tests/http/clients/{name}')
|
self.path = os.path.join(env.build_dir, f'tests/http/clients/{name}')
|
||||||
self.env = env
|
self.env = env
|
||||||
self._run_env = run_env
|
self._run_env = run_env
|
||||||
self._timeout = timeout if timeout else env.test_timeout
|
self._timeout = timeout if timeout else env.test_timeout
|
||||||
|
|||||||
@ -49,10 +49,9 @@ def init_config_from(conf_path):
|
|||||||
|
|
||||||
|
|
||||||
TESTS_HTTPD_PATH = os.path.dirname(os.path.dirname(__file__))
|
TESTS_HTTPD_PATH = os.path.dirname(os.path.dirname(__file__))
|
||||||
DEF_CONFIG = init_config_from(os.path.join(TESTS_HTTPD_PATH, 'config.ini'))
|
TOP_PATH = os.path.join(os.getcwd(), os.path.pardir)
|
||||||
|
DEF_CONFIG = init_config_from(os.path.join(TOP_PATH, 'tests', 'http', 'config.ini'))
|
||||||
TOP_PATH = os.path.dirname(os.path.dirname(TESTS_HTTPD_PATH))
|
CURL = os.path.join(TOP_PATH, 'src', 'curl')
|
||||||
CURL = os.path.join(TOP_PATH, 'src/curl')
|
|
||||||
|
|
||||||
|
|
||||||
class EnvConfig:
|
class EnvConfig:
|
||||||
@ -61,6 +60,7 @@ class EnvConfig:
|
|||||||
self.tests_dir = TESTS_HTTPD_PATH
|
self.tests_dir = TESTS_HTTPD_PATH
|
||||||
self.gen_dir = os.path.join(self.tests_dir, 'gen')
|
self.gen_dir = os.path.join(self.tests_dir, 'gen')
|
||||||
self.project_dir = os.path.dirname(os.path.dirname(self.tests_dir))
|
self.project_dir = os.path.dirname(os.path.dirname(self.tests_dir))
|
||||||
|
self.build_dir = TOP_PATH
|
||||||
self.config = DEF_CONFIG
|
self.config = DEF_CONFIG
|
||||||
# check cur and its features
|
# check cur and its features
|
||||||
self.curl = CURL
|
self.curl = CURL
|
||||||
@ -437,6 +437,10 @@ class Env:
|
|||||||
def project_dir(self) -> str:
|
def project_dir(self) -> str:
|
||||||
return self.CONFIG.project_dir
|
return self.CONFIG.project_dir
|
||||||
|
|
||||||
|
@property
|
||||||
|
def build_dir(self) -> str:
|
||||||
|
return self.CONFIG.build_dir
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def ca(self):
|
def ca(self):
|
||||||
return self._ca
|
return self._ca
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user