1
0
mirror of https://github.com/apache/httpd.git synced 2026-10-23 22:49:01 +03:00
Files
apache/test/pyhttpd/runtests.bat
Jean-Frederic Clere 93afb5c041 Speed up the tests and xfail some more.
This closes  #753



git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1938094 13f79535-47bb-0310-9956-ffa450edef68
2026-09-11 05:29:01 +00:00

96 lines
3.2 KiB
Batchfile

@echo off
rem
rem runtests.bat -- run the pyhttpd modules/ test suite on Windows.
rem
rem This is the Windows equivalent of runtests.sh. It manages a local .venv
rem under pyhttpd/ so that pytest and the CGI helper scripts (which httpd
rem forks) both use the same Python with all required packages.
rem
rem Usage:
rem runtests.bat --httpd C:\path\httpd.exe --conf C:\path\httpd.conf
rem runtests.bat --httpd ... modules\http2 -- run a specific suite
rem runtests.bat --httpd ... -k post -v -- any pytest args pass through
rem
rem Environment overrides:
rem PYTHON path to python (auto-detected if not set)
rem PYHTTPD_TARGETS space-separated list of test paths (default: modules)
rem
setlocal enabledelayedexpansion
set "HERE=%~dp0"
rem Remove trailing backslash
if "%HERE:~-1%"=="\" set "HERE=%HERE:~0,-1%"
rem --- python location: find the newest native Windows Python 3.x -------------
if not defined PYTHON (
set PYTHON=
for /f "delims=" %%P in ('where python.exe 2^>nul') do (
if not defined PYTHON (
echo %%P | findstr /i "hostedtoolcache" >nul
if not errorlevel 1 set "PYTHON=%%P"
)
)
)
if not defined PYTHON (
for /f "delims=" %%D in ('dir /b /o-n "%LOCALAPPDATA%\Programs\Python\Python3*" 2^>nul') do (
if not defined PYTHON set "PYTHON=%LOCALAPPDATA%\Programs\Python\%%D\python.exe"
)
)
if not defined PYTHON (
for /f "delims=" %%D in ('dir /b /o-n "%PROGRAMFILES%\Python3*" 2^>nul') do (
if not defined PYTHON set "PYTHON=%PROGRAMFILES%\%%D\python.exe"
)
)
if not defined PYTHON (
echo runtests.bat: ERROR: Python interpreter not found. >&2
echo Install Python from https://www.python.org or set PYTHON=... >&2
exit /b 1
)
rem --- ensure the venv exists and is current ----------------------------------
set "PYTEST=%HERE%\.venv\Scripts\pytest.exe"
set "NEED_SYNC=0"
if not exist "%PYTEST%" set "NEED_SYNC=1"
if exist "%HERE%\.venv" (
for /f %%F in ('xcopy /D /L /Y "%HERE%\pyproject.toml" "%HERE%\.venv\" 2^>nul ^| C:\Windows\System32\find.exe /c "pyproject.toml"') do (
if %%F gtr 0 set "NEED_SYNC=1"
)
) else (
set "NEED_SYNC=1"
)
if "%NEED_SYNC%"=="1" (
%PYTHON% -m uv --version >nul 2>&1
if errorlevel 1 (
echo runtests.bat: ERROR: 'uv' is required but not installed. >&2
echo Install it from https://docs.astral.sh/uv/ and re-run. >&2
echo %PYTHON% -m pip install uv >&2
exit /b 1
)
echo runtests.bat: ^(re^)creating %HERE%\.venv via 'uv sync'... >&2
%PYTHON% -m uv sync --project "%HERE%"
if errorlevel 1 exit /b 1
copy /b "%HERE%\.venv" +,, "%HERE%\.venv" >nul 2>&1
)
rem --- run from test/ (parent of pyhttpd/) ------------------------------------
cd /d "%HERE%\.."
rem --- default target ----------------------------------------------------------
if defined PYHTTPD_TARGETS (
set "TARGETS=%PYHTTPD_TARGETS%"
) else (
set "TARGETS=modules"
)
rem --- Windows-specific exclusions --------------------------------------------
set "WIN_IGNORE=--ignore=modules\md"
set "WIN_SKIP=not test_800_websockets and not test_02_unix"
echo runtests.bat: "%PYTEST%" %WIN_IGNORE% -k "%WIN_SKIP%" %TARGETS% %* >&2
"%PYTEST%" %WIN_IGNORE% -k "%WIN_SKIP%" %TARGETS% %*
exit /b %errorlevel%