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 #37

Merged
merged 1 commit into from
Mar 3, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 3 additions & 2 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-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
php:
Expand All @@ -23,11 +23,12 @@ 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
ini-file: development
- run: composer install
- run: vendor/bin/phpunit --coverage-text
if: ${{ matrix.php >= 7.3 }}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# clue/reactphp-mq

[![CI status](https://github.com/clue/reactphp-mq/workflows/CI/badge.svg)](https://github.com/clue/reactphp-mq/actions)
[![CI status](https://github.com/clue/reactphp-mq/actions/workflows/ci.yml/badge.svg)](https://github.com/clue/reactphp-mq/actions)
[![installs on Packagist](https://img.shields.io/packagist/dt/clue/mq-react?color=blue&label=installs%20on%20Packagist)](https://packagist.org/packages/clue/mq-react)

Mini Queue, the lightweight in-memory message queue to concurrently do many (but not too many) things at once,
Expand Down Expand Up @@ -485,7 +485,7 @@ This project follows [SemVer](https://semver.org/).
This will install the latest supported version:

```bash
$ composer require clue/mq-react:^1.5
composer require clue/mq-react:^1.5
```

See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
Expand All @@ -500,13 +500,13 @@ To run the test suite, you first need to clone this repo and then install all
dependencies [through Composer](https://getcomposer.org/):

```bash
$ composer install
composer install
```

To run the test suite, go to the project root and run:

```bash
$ vendor/bin/phpunit
vendor/bin/phpunit
```

## License
Expand Down
18 changes: 11 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,24 @@
"email": "christian@clue.engineering"
}
],
"autoload": {
"psr-4": { "Clue\\React\\Mq\\": "src/" }
},
"autoload-dev": {
"psr-4": { "Clue\\Tests\\React\\Mq\\": "tests/" }
},
"require": {
"php": ">=5.3",
"react/promise": "^3 || ^2.2.1 || ^1.2.1"
},
"require-dev": {
"phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.35",
"phpunit/phpunit": "^9.6 || ^5.7 || ^4.8.36",
"react/async": "^4 || ^3 || ^2",
"react/event-loop": "^1.2",
"react/http": "^1.8"
},
"autoload": {
"psr-4": {
"Clue\\React\\Mq\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Clue\\Tests\\React\\Mq\\": "tests/"
}
}
}
18 changes: 13 additions & 5 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"
colors="true"
cacheResult="false"
colors="true"
convertDeprecationsToExceptions="true">
<testsuites>
<testsuite name="MQ React Test Suite">
<testsuite name="MQ 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>
15 changes: 11 additions & 4 deletions phpunit.xml.legacy
Original file line number Diff line number Diff line change
@@ -1,13 +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"
convertDeprecationsToExceptions="true">
colors="true">
<testsuites>
<testsuite name="MQ React Test Suite">
<testsuite name="MQ Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
Expand All @@ -16,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>
3 changes: 2 additions & 1 deletion src/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ public function __invoke()
$queue[] = null;
end($queue);
$id = key($queue);
assert(is_int($id));

$deferred = new Deferred(function ($_, $reject) use (&$queue, $id, &$deferred) {
// forward cancellation to pending operation if it is currently executing
Expand Down Expand Up @@ -420,8 +421,8 @@ public function processQueue()
return;
}

/* @var $deferred Deferred */
$deferred = reset($this->queue);
assert($deferred instanceof Deferred);
unset($this->queue[key($this->queue)]);

// once number of pending jobs is below concurrency limit again:
Expand Down