svn commit: r1937102 - in httpd/httpd/trunk: . test/pytest_suite

[email protected]
Newsgroups gmane.comp.apache.cvs
Message-ID <178663370864.1587066.7011171251703342493@svn03-he-fi>
Author: jfclere
Date: Thu Aug 13 15:08:28 2026
New Revision: 1937102

Log:
build the test modules using cmake, that is for windows where we don't have apxs.

Added:
   httpd/httpd/trunk/test/pytest_suite/gen_test_header.py
Modified:
   httpd/httpd/trunk/CMakeLists.txt

Modified: httpd/httpd/trunk/CMakeLists.txt
==============================================================================
--- httpd/httpd/trunk/CMakeLists.txt	Thu Aug 13 13:28:23 2026	(r1937101)
+++ httpd/httpd/trunk/CMakeLists.txt	Thu Aug 13 15:08:28 2026	(r1937102)
@@ -429,6 +429,66 @@ SET(MODULE_LIST
   "modules/test/mod_policy+I+HTTP protocol compliance filters"
 )
 
+IF(BUILD_TEST_MODULES)
+  LIST(APPEND MODULE_LIST
+    "test/pyhttpd/mod_aptest/mod_aptest+A+Test module. Useful only for developers and testing purposes."
+    "test/modules/http1/mod_h1test/mod_h1test+A+Http/1 Test module. Useful only for developers and testing purposes."
+    "test/modules/http2/mod_h2test/mod_h2test+A+Http/2 Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/authany/mod_authany+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/client_add_filter/mod_client_add_filter+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/eat_post/mod_eat_post+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/echo_post/mod_echo_post+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/echo_post_chunk/mod_echo_post_chunk+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/fold/mod_fold+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/input_body_filter/mod_input_body_filter+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/list_modules/mod_list_modules+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/memory_track/mod_memory_track+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/nntp_like/mod_nntp_like+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/random_chunk/mod_random_chunk+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/test_apr_uri/mod_test_apr_uri+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/test_pass_brigade/mod_test_pass_brigade+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/test_rwrite/mod_test_rwrite+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/test_session/mod_test_session+A+Test module. Useful only for developers and testing purposes."
+    "test/pytest_suite/c-modules/test_utilities/mod_test_utilities+A+Test module. Useful only for developers and testing purposes."
+  )
+ENDIF()
+IF(BUILD_TEST_MODULES AND OPENSSL_FOUND)
+  LIST(APPEND MODULE_LIST
+    "test/pytest_suite/c-modules/test_ssl/mod_test_ssl+A+Test module. Useful only for developers and testing purposes."
+  )
+ENDIF()
+
+IF(BUILD_TEST_MODULES)
+  SET(PYTEST_CMODULES_DIR "${CMAKE_SOURCE_DIR}/test/pytest_suite/c-modules")
+  IF(WIN32)
+    file(GLOB _python_hints "$ENV{LOCALAPPDATA}/Programs/Python/Python3*"
+                            "$ENV{PROGRAMFILES}/Python3*")
+    find_program(PYTHON_EXE NAMES py python3 python
+      HINTS ${_python_hints}
+    )
+    IF(NOT PYTHON_EXE)
+      MESSAGE(FATAL_ERROR "Python interpreter not found, required for BUILD_TEST_MODULES")
+    ENDIF()
+    execute_process(
+      COMMAND "${PYTHON_EXE}" "${CMAKE_SOURCE_DIR}/test/pytest_suite/gen_test_header.py" "${PYTEST_CMODULES_DIR}/apache_httpd_test.h"
+      RESULT_VARIABLE _gen_header_rc
+    )
+    IF(NOT _gen_header_rc EQUAL 0)
+      MESSAGE(FATAL_ERROR "Failed to generate apache_httpd_test.h (exit ${_gen_header_rc})")
+    ENDIF()
+  ENDIF()
+  SET(PYTEST_CMODULE_DEFINES APACHE2 APACHE2_4)
+  FOREACH(pytest_mod
+      mod_authany mod_client_add_filter mod_eat_post mod_echo_post
+      mod_echo_post_chunk mod_fold mod_input_body_filter mod_list_modules
+      mod_memory_track mod_nntp_like mod_random_chunk mod_test_apr_uri
+      mod_test_pass_brigade mod_test_rwrite mod_test_session
+      mod_test_utilities mod_test_ssl)
+    SET(${pytest_mod}_extra_defines ${PYTEST_CMODULE_DEFINES})
+  ENDFOREACH()
+  SET(mod_test_session_extra_libs mod_session)
+ENDIF()
+
 # Track which modules actually built have APIs to link against.
 SET(installed_mod_libs_exps)
 
@@ -753,6 +813,12 @@ SET(HTTPD_INCLUDE_DIRECTORIES
   ${PCRE_INCLUDE_DIR}
 )
 
+IF(BUILD_TEST_MODULES)
+  LIST(APPEND HTTPD_INCLUDE_DIRECTORIES
+    ${CMAKE_CURRENT_SOURCE_DIR}/test/pytest_suite/c-modules
+  )
+ENDIF()
+
 # The .h files we install from outside the main include directory
 # largely parallel the include directories above.
 SET(other_installed_h
@@ -876,8 +942,8 @@ FOREACH (mod ${MODULE_PATHS})
 
     # Extra defines?
     SET(mod_extra_defines "${mod_name}_extra_defines")
-    IF(NOT ${${mod_extra_defines}} STREQUAL "")
-      SET_TARGET_PROPERTIES(${mod_name} PROPERTIES COMPILE_DEFINITIONS ${${mod_extra_defines}})
+    IF(NOT "${${mod_extra_defines}}" STREQUAL "")
+      TARGET_COMPILE_DEFINITIONS(${mod_name} PRIVATE ${${mod_extra_defines}})
     ENDIF()
 
     # Extra includes?

Added: httpd/httpd/trunk/test/pytest_suite/gen_test_header.py
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ httpd/httpd/trunk/test/pytest_suite/gen_test_header.py	Thu Aug 13 15:08:28 2026	(r1937102)
@@ -0,0 +1,33 @@
+#!/usr/bin/env python3
+"""Generate apache_httpd_test.h for CMake builds.
+
+Calls the same generate_header() from apache_pytest/cmodules.py that
+the Unix/apxs build uses, but without importing the full apache_pytest
+package (which requires httpx and other test dependencies).
+"""
+import sys
+import types
+from pathlib import Path
+
+# Stub out the apache_pytest package so cmodules.py can be loaded
+# without pulling in httpx and other test-only dependencies.
+pkg = types.ModuleType('apache_pytest')
+pkg.__path__ = [str(Path(__file__).parent / 'apache_pytest')]
+sys.modules['apache_pytest'] = pkg
+
+probe = types.ModuleType('apache_pytest.probe')
+
+class _HttpdInfo:
+    pass
+
+probe.HttpdInfo = _HttpdInfo
+sys.modules['apache_pytest.probe'] = probe
+
+from apache_pytest.cmodules import generate_header  # noqa: E402
+
+if __name__ == '__main__':
+    if len(sys.argv) > 1:
+        dest = Path(sys.argv[1])
+    else:
+        dest = Path(__file__).parent / 'c-modules' / 'apache_httpd_test.h'
+    generate_header(dest)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.