Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update test suite and report failed assertions #264

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 51 additions & 24 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
PHPUnit:
name: PHPUnit (PHP ${{ matrix.php }})
runs-on: ubuntu-18.04 # legacy Ubuntu 18.04 for legacy libevent
runs-on: ubuntu-22.04
strategy:
matrix:
php:
Expand All @@ -24,24 +24,46 @@ jobs:
- 5.4
- 5.3
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
- run: sudo apt-get update && sudo apt-get install libevent-dev
- name: Install ext-event on PHP >= 5.4
run: |
echo "yes" | sudo pecl install event
# explicitly enable extensions in php.ini on PHP 5.6+
php -r 'exit((int)(PHP_VERSION_ID >= 50600));' || echo "extension=event.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')"
if: ${{ matrix.php >= 5.4 }}
- name: Install ext-ev on PHP >= 5.4
run: |
echo "yes" | sudo pecl install ev
# explicitly enable extensions in php.ini on PHP 5.6+
php -r 'exit((int)(PHP_VERSION_ID >= 50600));' || echo "extension=ev.so" | sudo tee -a "$(php -r 'echo php_ini_loaded_file();')"
if: ${{ matrix.php >= 5.4 }}
ini-file: development
ini-values: disable_functions='' # do not disable PCNTL functions on PHP < 8.1
extensions: sockets, pcntl ${{ matrix.php >= 5.6 && ', event' || '' }} ${{ matrix.php >= 5.4 && ', ev' || '' }}
env:
fail-fast: true # fail step if any extension can not be installed
- run: composer install
- run: vendor/bin/phpunit --coverage-text
if: ${{ matrix.php >= 7.3 }}
- run: vendor/bin/phpunit --coverage-text -c phpunit.xml.legacy
if: ${{ matrix.php < 7.3 }}

PHPUnit-Unstable:
name: PHPUnit (Unstable PHP ${{ matrix.php }})
runs-on: ubuntu-20.04
continue-on-error: true
strategy:
matrix:
php:
- 7.4
- 7.3
- 7.2
- 7.1
- 7.0
- 5.6
- 5.5
- 5.4
- 5.3
steps:
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
ini-file: development
extensions: sockets, pcntl
- name: Install ext-uv on PHP 7.x
run: |
sudo add-apt-repository ppa:ondrej/php -y && sudo apt-get update -q && sudo apt-get install libuv1-dev
Expand All @@ -50,6 +72,7 @@ jobs:
if: ${{ matrix.php >= 7.0 && matrix.php < 8.0 }}
- name: Install legacy ext-libevent on PHP < 7.0
run: |
sudo apt-get update && sudo apt-get install libevent-dev
curl http://pecl.php.net/get/libevent-0.1.0.tgz | tar -xz
pushd libevent-0.1.0
phpize
Expand Down Expand Up @@ -78,7 +101,7 @@ jobs:

PHPUnit-Windows:
name: PHPUnit (PHP ${{ matrix.php }} on Windows)
runs-on: windows-2019
runs-on: windows-2022
continue-on-error: true
strategy:
matrix:
Expand All @@ -91,11 +114,12 @@ jobs:
- 7.2
- 7.1
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
coverage: xdebug
ini-file: development
extensions: sockets,event # future: add uv-beta (installs, but can not load)
- run: composer install
- run: vendor/bin/phpunit --coverage-text
Expand All @@ -105,13 +129,16 @@ jobs:

PHPUnit-hhvm:
name: PHPUnit (HHVM)
runs-on: ubuntu-18.04
runs-on: ubuntu-22.04
continue-on-error: true
steps:
- uses: actions/checkout@v2
- uses: azjezz/setup-hhvm@v1
- uses: actions/checkout@v3
- run: cp "$(which composer)" composer.phar && ./composer.phar self-update --2.2 # downgrade Composer for HHVM
- name: Run hhvm composer.phar install
uses: docker://hhvm/hhvm:3.30-lts-latest
with:
args: hhvm composer.phar install
- name: Run hhvm vendor/bin/phpunit
uses: docker://hhvm/hhvm:3.30-lts-latest
with:
version: lts-3.30
- run: composer self-update --2.2 # downgrade Composer for HHVM
- run: hhvm $(which composer) install
- run: hhvm vendor/bin/phpunit
args: hhvm vendor/bin/phpunit
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# EventLoop Component
# EventLoop

[![CI status](https://github.com/reactphp/event-loop/actions/workflows/ci.yml/badge.svg)](https://github.com/reactphp/event-loop/actions)
[![installs on Packagist](https://img.shields.io/packagist/dt/react/event-loop?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/react/event-loop)
Expand All @@ -10,7 +10,7 @@ same event loop. This component provides a common `LoopInterface` that any
library can target. This allows them to be used in the same loop, with one
single [`run()`](#run) call that is controlled by the user.

**Table of Contents**
**Table of contents**

* [Quickstart example](#quickstart-example)
* [Usage](#usage)
Expand Down Expand Up @@ -897,7 +897,7 @@ See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
This project aims to run on any platform and thus does not require any PHP
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
HHVM.
It's *highly recommended to use PHP 7+* for this project.
It's *highly recommended to use the latest supported PHP version* for this project.

Installing any of the event loop extensions is suggested, but entirely optional.
See also [event loop implementations](#loop-implementations) for more details.
Expand Down
10 changes: 4 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,19 @@
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35"
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36"
},
"suggest": {
"ext-event": "~1.0 for ExtEventLoop",
"ext-pcntl": "For signal handling support when using the StreamSelectLoop",
"ext-uv": "* for ExtUvLoop"
"ext-pcntl": "For signal handling support when using the StreamSelectLoop"
},
"autoload": {
"psr-4": {
"React\\EventLoop\\": "src"
"React\\EventLoop\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"React\\Tests\\EventLoop\\": "tests"
"React\\Tests\\EventLoop\\": "tests/"
}
}
}
16 changes: 12 additions & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with new format for PHPUnit 9.3+ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
<!-- PHPUnit configuration file with new format for PHPUnit 9.6+ -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.6/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResult="false"
colors="true"
convertDeprecationsToExceptions="true">
<testsuites>
<testsuite name="React test suite">
<testsuite name="EventLoop Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand All @@ -17,4 +17,12 @@
<directory>./src/</directory>
</include>
</coverage>
<php>
<ini name="error_reporting" value="-1" />
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
<!-- <ini name="zend.assertions" value="1" /> -->
<ini name="assert.active" value="1" />
<ini name="assert.exception" value="1" />
<ini name="assert.bail" value="0" />
</php>
</phpunit>
12 changes: 10 additions & 2 deletions phpunit.xml.legacy
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>

<!-- PHPUnit configuration file with old format for PHPUnit 9.2 or older -->
<!-- PHPUnit configuration file with old format for legacy PHPUnit -->
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/4.8/phpunit.xsd"
bootstrap="vendor/autoload.php"
colors="true">
<testsuites>
<testsuite name="React test suite">
<testsuite name="EventLoop Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand All @@ -15,4 +15,12 @@
<directory>./src/</directory>
</whitelist>
</filter>
<php>
<ini name="error_reporting" value="-1" />
<!-- Evaluate assertions, requires running with "php -d zend.assertions=1 vendor/bin/phpunit" -->
<!-- <ini name="zend.assertions" value="1" /> -->
<ini name="assert.active" value="1" />
<ini name="assert.exception" value="1" />
<ini name="assert.bail" value="0" />
</php>
</phpunit>
18 changes: 16 additions & 2 deletions tests/AbstractLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,11 +657,13 @@ public function testRemoveSignalNotRegisteredIsNoOp()

/**
* @requires extension pcntl
* @requires function posix_kill()
* @requires function posix_getpid()
*/
public function testSignal()
{
if (!function_exists('posix_kill') || !function_exists('posix_getpid')) {
$this->markTestSkipped('Signal test skipped because functions "posix_kill" and "posix_getpid" are missing.');
if ($this->loop instanceof StreamSelectLoop && !(\function_exists('pcntl_signal') && \function_exists('pcntl_signal_dispatch'))) {
$this->markTestSkipped('Signal handling with StreamSelectLoop requires pcntl_signal() and pcntl_signal_dispatch(), see also disable_functions');
}

$called = false;
Expand Down Expand Up @@ -696,6 +698,10 @@ public function testSignal()
*/
public function testSignalMultipleUsagesForTheSameListener()
{
if ($this->loop instanceof StreamSelectLoop && !(\function_exists('pcntl_signal') && \function_exists('pcntl_signal_dispatch'))) {
$this->markTestSkipped('Signal handling with StreamSelectLoop requires pcntl_signal() and pcntl_signal_dispatch(), see also disable_functions');
}

$funcCallCount = 0;
$func = function () use (&$funcCallCount) {
$funcCallCount++;
Expand Down Expand Up @@ -723,6 +729,10 @@ public function testSignalMultipleUsagesForTheSameListener()
*/
public function testSignalsKeepTheLoopRunning()
{
if ($this->loop instanceof StreamSelectLoop && !(\function_exists('pcntl_signal') && \function_exists('pcntl_signal_dispatch'))) {
$this->markTestSkipped('Signal handling with StreamSelectLoop requires pcntl_signal() and pcntl_signal_dispatch(), see also disable_functions');
}

$loop = $this->loop;
$function = function () {};
$this->loop->addSignal(SIGUSR1, $function);
Expand All @@ -739,6 +749,10 @@ public function testSignalsKeepTheLoopRunning()
*/
public function testSignalsKeepTheLoopRunningAndRemovingItStopsTheLoop()
{
if ($this->loop instanceof StreamSelectLoop && !(\function_exists('pcntl_signal') && \function_exists('pcntl_signal_dispatch'))) {
$this->markTestSkipped('Signal handling with StreamSelectLoop requires pcntl_signal() and pcntl_signal_dispatch(), see also disable_functions');
}

$loop = $this->loop;
$function = function () {};
$this->loop->addSignal(SIGUSR1, $function);
Expand Down
4 changes: 4 additions & 0 deletions tests/StreamSelectLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ public function signalProvider()
* Test signal interrupt when no stream is attached to the loop
* @dataProvider signalProvider
* @requires extension pcntl
* @requires function pcntl_signal()
* @requires function pcntl_signal_dispatch()
*/
public function testSignalInterruptNoStream($signal)
{
Expand Down Expand Up @@ -160,6 +162,8 @@ public function testSignalInterruptNoStream($signal)
* Test signal interrupt when a stream is attached to the loop
* @dataProvider signalProvider
* @requires extension pcntl
* @requires function pcntl_signal()
* @requires function pcntl_signal_dispatch()
*/
public function testSignalInterruptWithStream($signal)
{
Expand Down