]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
tests: allow pytests to run in out-of-tree builds
authorDan Fandrich <dan@coneharvesters.com>
Thu, 10 Oct 2024 17:44:56 +0000 (10:44 -0700)
committerDan Fandrich <dan@coneharvesters.com>
Sat, 12 Oct 2024 17:47:57 +0000 (10:47 -0700)
Some of the files it needs are in the build directory but the code did
not make a distinction.

Closes #15257

tests/CMakeLists.txt
tests/http/testenv/client.py
tests/http/testenv/env.py

index 9b6a3a42b1c19ae3350df7f7bb87e5a8d59fd371..ff7e1159359e89dcb76424d70c250ae933dc6990 100644 (file)
@@ -72,7 +72,6 @@ function(add_pytest _targetname _test_flags)
   endif()
   string(REPLACE " " ";" _test_flags_list "${_test_flags}")
   add_custom_target(${_targetname}
-    WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
     COMMAND pytest ${_test_flags_list} "${CMAKE_CURRENT_SOURCE_DIR}/http"
     DEPENDS "${_depends}"
     VERBATIM USES_TERMINAL
index cb6be1ddffd46ab90eeafd19ce789bfd159015b8..3981752ec49e3e4a139641e765ce0da71e4541af 100644 (file)
@@ -44,7 +44,7 @@ class LocalClient:
                  timeout: Optional[float] = None,
                  run_env: Optional[Dict[str,str]] = None):
         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._run_env = run_env
         self._timeout = timeout if timeout else env.test_timeout
index cf6a7e0fcdde1562c5739160a846de03a274d394..d382acf5ef2d5882a9f533f680f892d05a653dd7 100644 (file)
@@ -49,10 +49,9 @@ def init_config_from(conf_path):
 
 
 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.dirname(os.path.dirname(TESTS_HTTPD_PATH))
-CURL = os.path.join(TOP_PATH, 'src/curl')
+TOP_PATH = os.path.join(os.getcwd(), os.path.pardir)
+DEF_CONFIG = init_config_from(os.path.join(TOP_PATH, 'tests', 'http', 'config.ini'))
+CURL = os.path.join(TOP_PATH, 'src', 'curl')
 
 
 class EnvConfig:
@@ -61,6 +60,7 @@ class EnvConfig:
         self.tests_dir = TESTS_HTTPD_PATH
         self.gen_dir = os.path.join(self.tests_dir, 'gen')
         self.project_dir = os.path.dirname(os.path.dirname(self.tests_dir))
+        self.build_dir = TOP_PATH
         self.config = DEF_CONFIG
         # check cur and its features
         self.curl = CURL
@@ -437,6 +437,10 @@ class Env:
     def project_dir(self) -> str:
         return self.CONFIG.project_dir
 
+    @property
+    def build_dir(self) -> str:
+        return self.CONFIG.build_dir
+
     @property
     def ca(self):
         return self._ca