Skip to content

Commit

Permalink
appveyor add MSYS2 test
Browse files Browse the repository at this point in the history
  • Loading branch information
RoDuth committed Dec 19, 2024
1 parent 05345ac commit 28d67af
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 5 deletions.
7 changes: 7 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,17 @@ environment:
MYSQL_PATH: "C:\\Program Files\\MySQL\\MySQL Server 8.0"
# the cache should always be saved, even on failure, to be available for the next run
APPVEYOR_SAVE_CACHE_ON_ERROR: "true"
TEST_MSYS2: "false"

matrix:
# all the Python versions to be tested, both 32-bit and 64-bit
# ref: https://www.appveyor.com/docs/windows-images-software/#python
- PYTHON_HOME: "C:\\Python313-x64"
CHERE_INVOKING: 1
MSYSTEM: UCRT64
# breaks $python_arch in install.ps1 but we don't need it here.
PATH: C:\msys64\usr\bin;%PATH%
TEST_MSYS2: "true"
- PYTHON_HOME: "C:\\Python313-x64"
- PYTHON_HOME: "C:\\Python313"
- PYTHON_HOME: "C:\\Python312-x64"
Expand Down
8 changes: 6 additions & 2 deletions appveyor/after_test.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
IF "%TEST_MSYS2%" == "true" (
ECHO *** MSYS2 - Skipping generation of the wheel file
GOTO :end
)
IF "%APVYR_GENERATE_WHEELS%" == "true" (
ECHO *** pip install build/wheel modules
"%PYTHON_HOME%\python" -m pip install build wheel --quiet --no-warn-script-location
Expand All @@ -7,8 +11,8 @@ IF "%APVYR_GENERATE_WHEELS%" == "true" (
ECHO.
ECHO *** \dist directory listing:
DIR /B dist
ECHO.
) ELSE (
ECHO *** Skipping generation of the wheel file
ECHO.
)
:end
ECHO.
33 changes: 33 additions & 0 deletions appveyor/build_script.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ ECHO APVYR_GENERATE_WHEELS : %APVYR_GENERATE_WHEELS%
ECHO APVYR_VERBOSE : %APVYR_VERBOSE%
ECHO.
ECHO PYTHON_HOME : %PYTHON_HOME%
ECHO TEST_MSYS2 : %TEST_MSYS2%
ECHO MSSQL_INSTANCE: %MSSQL_INSTANCE%
ECHO POSTGRES_PATH : %POSTGRES_PATH%
ECHO MYSQL_PATH : %MYSQL_PATH%

ECHO.
IF "%TEST_MSYS2%" == "true" GOTO :msys2
ECHO *** Get build info and compiler for the current Python installation:
"%PYTHON_HOME%\python" -c "import platform; print(platform.python_build(), platform.python_compiler())"

Expand Down Expand Up @@ -51,4 +53,35 @@ ECHO.
ECHO *** Get version of the built pyodbc module:
"%PYTHON_HOME%\python" -c "import pyodbc; print(pyodbc.version)"

GOTO :end

:msys2
ECHO *** Get build info and compiler for the current Python installation:
bash -lc "python -c ""import platform; print(platform.python_build(), platform.python_compiler())"""

ECHO.
bash -lc "python -m pip freeze --all"

ECHO.
ECHO *** Installing pyodbc...
SET PYTHON_ARGS=.
IF "%APVYR_VERBOSE%" == "true" (
SET PYTHON_ARGS=--verbose %PYTHON_ARGS%
)
SET PIP_BREAK_SYSTEM_PACKAGES=1
bash -lc "python -m pip install %PYTHON_ARGS%"
IF ERRORLEVEL 1 (
ECHO *** ERROR: pyodbc install failed
EXIT 1
)

ECHO.
ECHO *** pip freeze...
bash -lc "python -m pip freeze --all"

ECHO.
ECHO *** Get version of the built pyodbc module:
bash -lc "python -c ""import pyodbc; print(pyodbc.version)"""

:end
ECHO.
11 changes: 9 additions & 2 deletions appveyor/install.cmd
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
ECHO *** pip install pytest and other dev requirements ***
"%PYTHON_HOME%\python" -m pip install -r requirements-dev.txt --quiet --no-warn-script-location
IF "%TEST_MSYS2%" == "true" (
ECHO *** pacman install dev requirements ***
bash -lc "pacman --noconfirm -Syuu"
bash -lc "pacman --noconfirm -Syuu"
bash -lc "pacman --noconfirm --needed -S - < ./appveyor/mingw_pkglist.txt"
) ELSE (
ECHO *** pip install pytest and other dev requirements ***
"%PYTHON_HOME%\python" -m pip install -r requirements-dev.txt --quiet --no-warn-script-location
)
ECHO.
35 changes: 34 additions & 1 deletion appveyor/test_script.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ SET OVERALL_RESULT=0

REM Output a list of the ODBC drivers available to pyodbc
ECHO *** Available ODBC Drivers:
"%PYTHON_HOME%\python" -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))"
IF "%TEST_MSYS2%" == "true" (
bash -lc "python -c ""import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))"""
) ELSE (
"%PYTHON_HOME%\python" -c "import pyodbc; print('\n'.join(sorted(pyodbc.drivers())))"
)


REM check if any testing should be done at all
Expand Down Expand Up @@ -43,6 +47,14 @@ IF ERRORLEVEL 1 (
)


REM check if only msys2 tests
IF "%TEST_MSYS2%" == "true" (
ECHO.
ECHO *** testing MSYS2
GOTO :msys2
)


:mssql2
REM Native Client 11.0 is so old, it might not be available on the server
SET DRIVER={SQL Server Native Client 11.0}
Expand Down Expand Up @@ -216,6 +228,27 @@ IF "%APVYR_VERBOSE%" == "true" (
%PYTHON_ARGS% "tests\mysql_test.py"
IF ERRORLEVEL 1 SET OVERALL_RESULT=1

GOTO :end

:msys2
SET DRIVER={ODBC Driver 17 for SQL Server}
SET PYODBC_SQLSERVER=Driver=%DRIVER%;Server=%MSSQL_INSTANCE%;Database=test_db;UID=sa;PWD=Password12!;
ECHO.
ECHO *** Run tests using driver: "%DRIVER%"
bash -lc "python appveyor/test_connect.py '%PYODBC_SQLSERVER%'"
IF ERRORLEVEL 1 (
ECHO *** ERROR: Could not connect using the connection string:
ECHO "%PYODBC_SQLSERVER%"
SET OVERALL_RESULT=1
GOTO :end
)
SET PYTHON_ARGS=-m pytest
IF "%APVYR_VERBOSE%" == "true" (
SET PYTHON_ARGS=%PYTHON_ARGS% --verbose
)
bash -lc "python %PYTHON_ARGS% tests/sqlserver_test.py"
IF ERRORLEVEL 1 SET OVERALL_RESULT=1


:end
ECHO.
Expand Down

0 comments on commit 28d67af

Please sign in to comment.