Skip to content

Commit

Permalink
Tests with some php-src PHPTs
Browse files Browse the repository at this point in the history
  • Loading branch information
dixyes committed Aug 1, 2024
1 parent cbadca0 commit 2c79cd1
Show file tree
Hide file tree
Showing 3 changed files with 239 additions and 0 deletions.
111 changes: 111 additions & 0 deletions .github/workflows/run-php-src-tests.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@

$ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$PSNativeCommandUseErrorActionPreference = $true

if ( "${env:GITHUB_WORKSPACE}" -Eq "" ) {
Write-Host "This script is intended to run in GitHub Actions environment only."
exit 1
}

$phpSrcRepo = "https://github.com/php/php-src.git"
if ( "${env:PHP_SRC_REPO}" -Ne "" ) {
$phpSrcRepo = "${env:PHP_SRC_REPO}"
}

$phpVersion = php -r "echo PHP_VERSION;"
if ( "$phpVersion" -Match '-dev$') {
$phpBranch = "master"
} else {
$phpBranch = "php-$phpVersion"
}

$includeTests = @(
"sapi/cli/tests",
"tests/basic",
"tests/output",
"tests/security",
"ext/curl/tests",
"ext/opcache/tests",
"ext/openssl/tests",
"ext/posix/tests",
"ext/pcntl/tests",
"ext/sockets/tests"
)

$excludeTests = @(
# hard coded object number
# fixme: can this be fixed?
"ext/opcache/tests/bug78986.phpt",
"ext/opcache/tests/bug79535.phpt",
"ext/opcache/tests/jit/assign_042.phpt",
"ext/opcache/tests/jit/assign_056.phpt",
"ext/opcache/tests/jit/assign_obj_op_002.phpt",
"ext/opcache/tests/jit/assign_obj_op_003.phpt",
"ext/opcache/tests/jit/assign_obj_ref_001.phpt",
"ext/opcache/tests/jit/closure_001.phpt",
"ext/opcache/tests/jit/fetch_obj_003.phpt",
"ext/opcache/tests/jit/fetch_obj_004.phpt",
"ext/opcache/tests/jit/fetch_obj_007.phpt",
"ext/opcache/tests/jit/gh12482.phpt",
"ext/opcache/tests/jit/mod_003.phpt",
"ext/opcache/tests/jit/mod_005.phpt",
"ext/opcache/tests/jmp_elim_004.phpt",
"ext/sockets/tests/socket_create_pair.phpt",
"ext/sockets/tests/socket_addrinfo_bind.phpt",
"ext/sockets/tests/socket_addrinfo_connect.phpt",
"ext/sockets/tests/socket_set_nonblock.phpt",
"ext/openssl/tests/bug81713.phpt",
"ext/openssl/tests/ecc.phpt",
"ext/openssl/tests/openssl_cms_decrypt_error.phpt",
"ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt",
"ext/openssl/tests/openssl_x509_free_basic.phpt",
"ext/curl/tests/curl_share_close_basic001.phpt",
"ext/curl/tests/curl_multi_init_basic.phpt",
"ext/curl/tests/curl_multi_close_basic001.phpt",
"ext/curl/tests/curl_multi_close_basic.phpt",
"ext/curl/tests/curl_int_cast.phpt",
"ext/curl/tests/curl_close_basic.phpt",
"ext/curl/tests/curl_basic_014.phpt",
"ext/curl/tests/bug72202.phpt",
"ext/curl/tests/bug48514.phpt",
# error message changed
"ext/openssl/tests/bug54992.phpt", # fixme: bad message
"ext/openssl/tests/bug65538_002.phpt",
"ext/openssl/tests/bug65729.phpt", # fixme: bad message
"ext/openssl/tests/bug68920.phpt",
"ext/openssl/tests/gh9310.phpt",
"ext/openssl/tests/san_peer_matching.phpt", # fixme: bad message
"ext/openssl/tests/stream_verify_peer_name_003.phpt", # fixme: bad message
"ext/curl/tests/bug78775.phpt",
# no readline support
"sapi/cli/tests/009.phpt",
"sapi/cli/tests/012-2.phpt"
)

$nproc = Get-CIMInstance -ClassName Win32_ComputerSystem | Select-Object -ExpandProperty NumberOfLogicalProcessors

# clone php-src
& git "clone" `
"--single-branch" `
"--branch" "${phpBranch}" `
"--depth" "1" `
"${phpSrcRepo}" `
"php-src"

# remove excluded tests
Set-Location -Path php-src
foreach ($excludeTest in $excludeTests) {
Remove-Item -Path $excludeTest -Recurse -Force -ErrorAction SilentlyContinue
}

# test it
& php "run-tests.php" `
"-d" "extension=swow" `
"-d" "opcache.enable_cli=on" `
"--show-diff" `
"--show-slow" "3000" `
"--set-timeout" "30" `
"--color" `
"-j$nproc" `
${includeTests}
109 changes: 109 additions & 0 deletions .github/workflows/run-php-src-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
#!/usr/bin/env bash

set -xeo pipefail

if [[ -z "${GITHUB_WORKSPACE}" ]]; then
echo "This script is intended to run in GitHub Actions environment only."
exit 1
fi

PHP_SRC_REPO="${PHP_SRC_REPO:-https://github.com/php/php-src.git}"

PHP_VERSION="$(php -r 'echo PHP_VERSION;')"
PHP_BRANCH="php-${PHP_VERSION}"
if [[ "${PHP_VERSION%%-dev}" != "${PHP_VERSION}" ]]; then
PHP_BRANCH=master
fi

INCLUDE_TESTS=(
sapi/cli/tests
tests/basic
tests/output
tests/security
ext/curl/tests
ext/opcache/tests
ext/openssl/tests
ext/posix/tests
ext/pcntl/tests
ext/sockets/tests
)

EXCLUDE_TESTS=(
# hard coded object number
# fixme: can this be fixed?
ext/opcache/tests/bug78986.phpt
ext/opcache/tests/bug79535.phpt
ext/opcache/tests/jit/assign_042.phpt
ext/opcache/tests/jit/assign_056.phpt
ext/opcache/tests/jit/assign_obj_op_002.phpt
ext/opcache/tests/jit/assign_obj_op_003.phpt
ext/opcache/tests/jit/assign_obj_ref_001.phpt
ext/opcache/tests/jit/closure_001.phpt
ext/opcache/tests/jit/fetch_obj_003.phpt
ext/opcache/tests/jit/fetch_obj_004.phpt
ext/opcache/tests/jit/fetch_obj_007.phpt
ext/opcache/tests/jit/gh12482.phpt
ext/opcache/tests/jit/mod_003.phpt
ext/opcache/tests/jit/mod_005.phpt
ext/opcache/tests/jmp_elim_004.phpt
ext/sockets/tests/socket_create_pair.phpt
ext/sockets/tests/socket_addrinfo_bind.phpt
ext/sockets/tests/socket_addrinfo_connect.phpt
ext/sockets/tests/socket_set_nonblock.phpt
ext/openssl/tests/bug81713.phpt
ext/openssl/tests/ecc.phpt
ext/openssl/tests/openssl_cms_decrypt_error.phpt
ext/openssl/tests/openssl_pkcs7_decrypt_error.phpt
ext/openssl/tests/openssl_x509_free_basic.phpt
ext/curl/tests/curl_share_close_basic001.phpt
ext/curl/tests/curl_multi_init_basic.phpt
ext/curl/tests/curl_multi_close_basic001.phpt
ext/curl/tests/curl_multi_close_basic.phpt
ext/curl/tests/curl_int_cast.phpt
ext/curl/tests/curl_close_basic.phpt
ext/curl/tests/curl_basic_014.phpt
ext/curl/tests/bug72202.phpt
ext/curl/tests/bug48514.phpt
# error message changed
ext/openssl/tests/bug54992.phpt # fixme: bad message
ext/openssl/tests/bug65538_002.phpt
ext/openssl/tests/bug65729.phpt # fixme: bad message
ext/openssl/tests/bug68920.phpt
ext/openssl/tests/gh9310.phpt
ext/openssl/tests/san_peer_matching.phpt # fixme: bad message
ext/openssl/tests/stream_verify_peer_name_003.phpt # fixme: bad message
ext/curl/tests/bug78775.phpt
# no readline support
sapi/cli/tests/009.phpt
sapi/cli/tests/012-2.phpt
)

if [[ "$(uname -s)" == "Darwin" ]]
then
NPROC=$(sysctl -n hw.ncpu)
else
NPROC=$(nproc)
fi

# clone php-src
git clone \
--single-branch \
--branch "${PHP_BRANCH}" \
--depth 1 \
"$PHP_SRC_REPO" \
php-src

# remove excluded tests
cd php-src
rm -rf "${EXCLUDE_TESTS[@]}"

# test it
php run-tests.php \
-d extension="${GITHUB_WORKSPACE}/ext/.libs/swow.so" \
-d opcache.enable_cli=on \
--show-diff \
--show-slow 3000 \
--set-timeout 30 \
--color \
"-j$NPROC" \
"${INCLUDE_TESTS[@]}"
19 changes: 19 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ jobs:
continue-on-error: true
run: php --ri pcov && composer test-library-with-pcov

- name: Run PHPT from php-src
id: test-php-src
continue-on-error: true
run: |
./.github/workflows/run-php-src-tests.sh
- name: Fail if test-extension failed
if: steps.test-extension.outcome != 'success'
run: exit 1
Expand Down Expand Up @@ -226,6 +232,12 @@ jobs:
continue-on-error: true
run: php --ri pcov && composer test-library-with-pcov

- name: Run PHPT from php-src
id: test-php-src
continue-on-error: true
run: |
./.github/workflows/run-php-src-tests.sh
- name: Fail if test-extension failed
if: steps.test-extension.outcome != 'success'
run: exit 1
Expand Down Expand Up @@ -381,6 +393,13 @@ jobs:
--modules php_swow.dll `
-- C:\tools\php\php.exe C:\tools\php\composer.phar test-library
- name: Run PHPT from php-src
shell: pwsh
id: test-php-src
continue-on-error: true
run: |
./.github/workflows/run-php-src-tests.ps1
- name: Fail if test-extension failed
if: steps.test-extension.outcome != 'success'
run: exit 1
Expand Down

0 comments on commit 2c79cd1

Please sign in to comment.