1@echo off
2
3set NO_INTERACTION=1
4set REPORT_EXIT_STATUS=1
5set SKIP_IO_CAPTURE_TESTS=1
6
7if /i "%APPVEYOR_REPO_BRANCH:~0,4%" equ "php-" (
8	set BRANCH=%APPVEYOR_REPO_BRANCH:~4,3%
9	set STABILITY=stable
10) else (
11	set BRANCH=master
12	set STABILITY=staging
13)
14set DEPS_DIR=%PHP_BUILD_CACHE_BASE_DIR%\deps-%BRANCH%-%PHP_SDK_VS%-%PHP_SDK_ARCH%
15if not exist "%DEPS_DIR%" (
16	echo "%DEPS_DIR%" doesn't exist
17	exit /b 3
18)
19
20rem setup MySQL related exts
21set MYSQL_PWD=Password12!
22set MYSQL_TEST_PASSWD=%MYSQL_PWD%
23set MYSQL_TEST_USER=root
24set MYSQL_TEST_HOST=127.0.0.1
25set MYSQL_TEST_PORT=3306
26set PDO_MYSQL_TEST_USER=%MYSQL_TEST_USER%
27set PDO_MYSQL_TEST_PASS=%MYSQL_PWD%
28set PDO_MYSQL_TEST_HOST=%MYSQL_TEST_HOST%
29set PDO_MYSQL_TEST_PORT=%MYSQL_TEST_PORT%
30set PDO_MYSQL_TEST_DSN=mysql:host=%PDO_MYSQL_TEST_HOST%;port=%PDO_MYSQL_TEST_PORT%;dbname=test
31"C:\Program Files\MySql\MySQL Server 5.7\bin\mysql.exe" --user=%MYSQL_TEST_USER% -e "CREATE DATABASE IF NOT EXISTS test"
32if %errorlevel% neq 0 exit /b 3
33
34rem setup PostgreSQL related exts
35set PGUSER=postgres
36set PGPASSWORD=Password12!
37rem set PGSQL_TEST_CONNSTR=host=127.0.0.1 dbname=test port=5432 user=postgres password=Password12!
38echo ^<?php $conn_str = "host=127.0.0.1 dbname=test port=5432 user=%PGUSER% password=%PGPASSWORD%"; ?^> >> "./ext/pgsql/tests/config.inc"
39set PDO_PGSQL_TEST_DSN=pgsql:host=127.0.0.1 port=5432 dbname=test user=%PGUSER% password=%PGPASSWORD%
40"C:\Program Files\PostgreSQL\10\bin\createdb.exe" test
41if %errorlevel% neq 0 exit /b 3
42
43rem setup ODBC related exts
44set ODBC_TEST_USER=sa
45set ODBC_TEST_PASS=Password12!
46set ODBC_TEST_DSN=Driver={ODBC Driver 13 for SQL Server};Server=(local)\SQL2017;Database=master;uid=%ODBC_TEST_USER%;pwd=%ODBC_TEST_PASS%
47set PDOTEST_DSN=odbc:%ODBC_TEST_DSN%
48
49rem prepare for ext/openssl
50if "%APPVEYOR%" equ "True" rmdir /s /q C:\OpenSSL-Win32 >NUL 2>NUL
51if "%APPVEYOR%" equ "True" rmdir /s /q C:\OpenSSL-Win64 >NUL 2>NUL
52if "%PLATFORM%" == "x64" (
53	set OPENSSLDIR="C:\Program Files\Common Files\SSL"
54) else (
55	set OPENSSLDIR="C:\Program Files (x86)\Common Files\SSL"
56)
57mkdir %OPENSSLDIR%
58if %errorlevel% neq 0 exit /b 3
59copy %DEPS_DIR%\template\ssl\openssl.cnf %OPENSSLDIR%
60if %errorlevel% neq 0 exit /b 3
61rem set OPENSSL_CONF=%OPENSSLDIR%\openssl.cnf
62set OPENSSL_CONF=
63rem set SSLEAY_CONF=
64
65rem prepare for Opcache
66if "%OPCACHE%" equ "1" set OPCACHE_OPTS=-d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.protect_memory=1 -d opcache.jit_buffer_size=16M
67
68rem prepare for enchant
69mkdir C:\usr\local\lib\enchant-2
70if %errorlevel% neq 0 exit /b 3
71copy %DEPS_DIR%\bin\libenchant2_hunspell.dll C:\usr\local\lib\enchant-2
72if %errorlevel% neq 0 exit /b 3
73reg add HKEY_CURRENT_USER\SOFTWARE\Enchant\Config /v Module_Dir /t REG_SZ /d c:\enchant_plugins
74if %errorlevel% neq 0 exit /b 3
75set PHP_BUILD_CACHE_ENCHANT_DICT_DIR=%PHP_BUILD_CACHE_BASE_DIR%\enchant_dict
76if not exist "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%" (
77	echo Creating %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%
78	mkdir "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%"
79)
80if not exist "%PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\en_US.aff" (
81	echo Fetching enchant dicts
82	pushd %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%
83	del /q *
84	powershell -Command wget http://windows.php.net/downloads/qa/appveyor/ext/enchant/dict.zip -OutFile dict.zip
85	unzip dict.zip
86	del /q dict.zip
87	popd
88)
89mkdir %LOCALAPPDATA%\enchant\hunspell
90copy %PHP_BUILD_CACHE_ENCHANT_DICT_DIR%\* %LOCALAPPDATA%\enchant\hunspell
91
92set TEST_PHPDBG_EXECUTABLE=%PHP_BUILD_OBJ_DIR%\Release
93if "%THREAD_SAFE%" equ "1" set TEST_PHPDBG_EXECUTABLE=%TEST_PHPDBG_EXECUTABLE%_TS
94set TEST_PHPDBG_EXECUTABLE=%TEST_PHPDBG_EXECUTABLE%\phpdbg.exe
95
96mkdir c:\tests_tmp
97
98set TEST_PHP_JUNIT=c:\junit.out.xml
99
100cd "%APPVEYOR_BUILD_FOLDER%"
101nmake test TESTS="%OPCACHE_OPTS% -q --offline --show-diff --show-slow 1000 --set-timeout 120 --temp-source c:\tests_tmp --temp-target c:\tests_tmp %PARALLEL%"
102
103set EXIT_CODE=%errorlevel%
104
105appveyor PushArtifact %TEST_PHP_JUNIT%
106
107exit /b %EXIT_CODE%
108