8000 [WIP] Update .travis.yml for PHP 7 by cebe · Pull Request #45 · reactphp/event-loop · GitHub
[go: up one dir, main page]

Skip to content

[WIP] Update .travis.yml for PHP 7 #45

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

Merged
merged 3 commits into from
Mar 8, 2016
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
8 changes: 1 addition & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,8 @@ php:
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- hhvm-nightly

matrix:
allow_failures:
- php: hhvm
- php: hhvm-nightly
fast_finish: true

install: ./travis-init.sh

Expand Down
2 changes: 1 addition & 1 deletion src/ExtEventLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ private function unsubscribeStreamEvent($stream, $flag)
*/
private function createTimerCallback()
{
$this->timerCallback = function ($_, $_, $timer) {
$this->timerCallback = function ($_, $__, $timer) {
call_user_func($timer->getCallback(), $timer);

if (!$timer->isPeriodic() && $this->isTimerActive($timer)) {
Expand Down
2 changes: 1 addition & 1 deletion src/LibEventLoop.php
8000
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private function unsubscribeStreamEvent($stream, $flag)
*/
private function createTimerCallback()
{
$this->timerCallback = function ($_, $_, $timer) {
$this->timerCallback = function ($_, $__, $timer) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see why we would want this change, but for the reference only: Afaict this line is currently untested because the libevent extension does not (currently) compile under PHP 7, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, right. The code crashes because of this line when you try to include
this class. That's something that static analysis tools can stumble upon.

So this fixes that. But there's not actually a way to run this
implementation on PHP 7.

On Tuesday, 1 March 2016, Christian Lück notifications@github.com wrote:

In src/LibEventLoop.php
#45 (comment):

@@ -298,7 +298,7 @@ private function unsubscribeStreamEvent($stream, $flag)
*/
private function createTimerCallback()
{

  •    $this->timerCallback = function ($_, $_, $timer) {
    
  •    $this->timerCallback = function ($_, $__, $timer) {
    

I see why we would want this change, but for the reference only: Afaict
this line is currently untested because the libevent extension does not
compile under PHP 7, right?


Reply to this email directly or view it on GitHub
https://github.com/reactphp/event-loop/pull/45/files#r54551382.

Ondřej Mirtes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the confirmation, your reasoning makes perfect sense 👍

call_user_func($timer->getCallback(), $timer);

// Timer already cancelled ...
Expand Down
6 changes: 3 additions & 3 deletions tests/AbstractLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public function runShouldReturnWhenNoMoreFds()

$this->writeToStream($input, "foo\n");

$this->assertRunFasterThan(0.005);
$this->assertRunFasterThan(0.015);
}

/** @test */
Expand All @@ -194,7 +194,7 @@ public function stopShouldStopRunningLoop()
$this->assertRunFasterThan(0.005);
}

public function testStopShouldPreventRunFromBlocking()
public function testStopShouldPreventRunFromBlocking($timeLimit = 0.005)
{
$this->loop->addTimer(
1,
Expand All @@ -209,7 +209,7 @@ function () {
}
);

$this->assertRunFasterThan(0.005);
$this->assertRunFasterThan($timeLimit);
}

public function testIgnoreRemovedCallback()
Expand Down
11 changes: 11 additions & 0 deletions tests/StreamSelectLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ public function testStreamSelectTimeoutEmulation()
$this->assertGreaterThan(0.04, $interval);
}

public function testStopShouldPreventRunFromBlocking($timeLimit = 0.005)
{
if (defined('HHVM_VERSION')) {
// HHVM is a bit slow, so give it more time
parent::testStopShouldPreventRunFromBlocking(0.5);
} else {
parent::testStopShouldPreventRunFromBlocking($timeLimit);
}
}


public function signalProvider()
{
return [
Expand Down
40 changes: 22 additions & 18 deletions travis-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,29 @@ if [[ "$TRAVIS_PHP_VERSION" != "hhvm" &&
# install 'event' PHP extension
echo "yes" | pecl install event

# install 'libevent' PHP extension
curl http://pecl.php.net/get/libevent-0.1.0.tgz | tar -xz
pushd libevent-0.1.0
phpize
./configure
make
make install
popd
echo "extension=libevent.so" >> "$(php -r 'echo php_ini_loaded_file();')"
# install 'libevent' PHP extension (does not support php 7)
if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]]; then
curl http://pecl.php.net/get/libevent-0.1.0.tgz | tar -xz
pushd libevent-0.1.0
phpize
./configure
make
make install
popd
echo "extension=libevent.so" >> "$(php -r 'echo php_ini_loaded_file();')"
fi

# install 'libev' PHP ex 6D47 tension
git clone --recursive https://github.com/m4rw3r/php-libev
pushd php-libev
phpize
./configure --with-libev
make
make install
popd
echo "extension=libev.so" >> "$(php -r 'echo php_ini_loaded_file();')"
# install 'libev' PHP extension (does not support php 7)
if [[ "$TRAVIS_PHP_VERSION" != "7.0" ]]; then
git clone --recursive https://github.com/m4rw3r/php-libev
pushd php-libev
phpize
./configure --with-libev
make
make install
popd
echo "extension=libev.so" >> "$(php -r 'echo php_ini_loaded_file();')"
fi

fi

Expand Down
0