Skip to content

Commit def7699

Browse files
committed
Faster smoke testing in CI
1 parent 14a8693 commit def7699

File tree

6 files changed

+28
-23
lines changed

6 files changed

+28
-23
lines changed

.github/workflows/test-unit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ jobs:
2828

2929
- name: Configure PHP
3030
run: |
31-
install-php-extensions memcached sysvsem
3231
rm /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
3332
php --version
3433
@@ -37,6 +36,7 @@ jobs:
3736
if [ "${{ matrix.type }}" != "Phpunit" ] && [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpunit/phpunit ergebnis/phpunit-slow-test-detector --dev; fi
3837
if [ "${{ matrix.type }}" != "CodingStyle" ]; then composer remove --no-interaction --no-update friendsofphp/php-cs-fixer ergebnis/composer-normalize --dev; fi
3938
if [ "${{ matrix.type }}" != "StaticAnalysis" ]; then composer remove --no-interaction --no-update phpstan/\* --dev; fi
39+
composer remove --no-interaction --no-update ext-lzf ext-memcached ext-sysvsem --dev
4040
composer update --ansi --prefer-dist --no-interaction --no-progress --optimize-autoloader
4141
4242
- name: "Run tests (only for Phpunit)"

composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@
3939
"symfony/polyfill-php80": "^1.28"
4040
},
4141
"require-dev": {
42+
"ext-igbinary": "*",
43+
"ext-lzf": "*",
4244
"ext-memcached": "*",
4345
"ext-pcntl": "*",
4446
"ext-pdo": "*",
4547
"ext-pdo_mysql": "*",
4648
"ext-pdo_sqlite": "*",
49+
"ext-redis": "*",
4750
"ext-sysvsem": "*",
4851
"eloquent/liberator": "^2.0 || ^3.0",
4952
"ergebnis/composer-normalize": "^2.13",
@@ -62,7 +65,7 @@
6265
"suggest": {
6366
"ext-igbinary": "To use this library with PHP Redis igbinary serializer enabled.",
6467
"ext-lzf": "To use this library with PHP Redis lzf compression enabled.",
65-
"ext-pnctl": "Enables locking with flock without busy waiting in CLI scripts.",
68+
"ext-pcntl": "Enables locking with flock without busy waiting in CLI scripts.",
6669
"ext-redis": "To use this library with the PHP Redis extension.",
6770
"ext-sysvsem": "Enables locking using semaphores.",
6871
"predis/predis": "To use this library with predis."

src/Util/DoubleCheckedLocking.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414
*
1515
* You should not instantiate this class directly. Use
1616
* {@link \Malkusch\Lock\Mutex\Mutex::check()}.
17+
*
18+
* @internal
1719
*/
1820
class DoubleCheckedLocking
1921
{

src/Util/Loop.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,10 @@
1313
*/
1414
class Loop
1515
{
16-
/**
17-
* Minimum time that we want to wait, between lock checks. In micro seconds.
18-
*/
16+
/** Minimum time that we want to wait, between lock checks. In micro seconds. */
1917
private const MINIMUM_WAIT_US = 1e4; // 0.01 seconds
2018

21-
/**
22-
* Maximum time that we want to wait, between lock checks. In micro seconds.
23-
*/
19+
/** Maximum time that we want to wait, between lock checks. In micro seconds. */
2420
private const MAXIMUM_WAIT_US = 5e5; // 0.50 seconds
2521

2622
/** @var float The timeout in seconds */

tests/Mutex/MutexConcurrencyTest.php

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -251,18 +251,20 @@ public static function provideExecutionIsSerializedWhenLockedCases(): iterable
251251
return $lock->popsValue();
252252
}];
253253

254-
yield 'semaphore' => [static function () use ($filename): Mutex {
255-
$semaphore = sem_get(ftok($filename, 'b'));
256-
self::assertThat(
257-
$semaphore,
258-
self::logicalOr(
259-
self::isInstanceOf(\SysvSemaphore::class),
260-
new IsType(IsType::TYPE_RESOURCE)
261-
)
262-
);
263-
264-
return new SemaphoreMutex($semaphore);
265-
}];
254+
if (extension_loaded('sysvsem')) {
255+
yield 'semaphore' => [static function () use ($filename): Mutex {
256+
$semaphore = sem_get(ftok($filename, 'b'));
257+
self::assertThat(
258+
$semaphore,
259+
self::logicalOr(
260+
self::isInstanceOf(\SysvSemaphore::class),
261+
new IsType(IsType::TYPE_RESOURCE)
262+
)
263+
);
264+
265+
return new SemaphoreMutex($semaphore);
266+
}];
267+
}
266268

267269
if (getenv('MEMCACHE_HOST')) {
268270
yield 'memcached' => [static function ($timeout): Mutex {

tests/Mutex/MutexTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,11 @@ public static function provideMutexFactoriesCases(): iterable
8181
return $lock->popsValue();
8282
}];
8383

84-
yield 'SemaphoreMutex' => [static function (): Mutex {
85-
return new SemaphoreMutex(sem_get(ftok(__FILE__, 'a')));
86-
}];
84+
if (extension_loaded('sysvsem')) {
85+
yield 'SemaphoreMutex' => [static function (): Mutex {
86+
return new SemaphoreMutex(sem_get(ftok(__FILE__, 'a')));
87+
}];
88+
}
8789

8890
yield 'SpinlockMutex' => [static function (): Mutex {
8991
$lock = new class('test') extends SpinlockMutex {

0 commit comments

Comments
 (0)