Skip to content

Commit 9074a6d

Browse files
minor symfony#27779 [Lock] Fix SemaphoreStoreTest on OS X (ogizanagi)
This PR was merged into the 3.4 branch. Discussion ---------- [Lock] Fix SemaphoreStoreTest on OS X | Q | A | ------------- | --- | Branch? | 3.4 <!-- see below --> | Bug fix? | no | New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files --> | BC breaks? | no <!-- see https://symfony.com/bc --> | Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tests pass? | yes <!-- please add some, will be required by reviewers --> | Fixed tickets | symfony#27755 (review) <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | N/A As spotted in symfony#27755 (review), for OS X. If other OS X users could give it a try (`/phpunit src/Symfony/Component/Lock/ --filter=SemaphoreStoreTest`), that would be awesome. Commits ------- 9055611 [Lock] Fix SemaphoreStoreTest on OS X
2 parents 493ce7a + 9055611 commit 9074a6d

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/Symfony/Component/Lock/Tests/Store/SemaphoreStoreTest.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,22 @@ public function testResourceRemoval()
5050

5151
private function getOpenedSemaphores()
5252
{
53+
if ('Darwin' === PHP_OS) {
54+
$lines = explode(PHP_EOL, trim(`ipcs -s`));
55+
if (-1 === $start = array_search('Semaphores:', $lines)) {
56+
throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore list, got '.implode(PHP_EOL, $lines));
57+
}
58+
59+
return \count(\array_slice($lines, ++$start));
60+
}
61+
5362
$lines = explode(PHP_EOL, trim(`LC_ALL=C ipcs -su`));
5463
if ('------ Semaphore Status --------' !== $lines[0]) {
55-
throw new \Exception('Failed to extract list of opend semaphores. Expect a Semaphore status, got '.implode(PHP_EOL, $lines));
64+
throw new \Exception('Failed to extract list of opened semaphores. Expected a Semaphore status, got '.implode(PHP_EOL, $lines));
5665
}
5766
list($key, $value) = explode(' = ', $lines[1]);
5867
if ('used arrays' !== $key) {
59-
throw new \Exception('Failed to extract list of opend semaphores. Expect a used arrays key, got '.implode(PHP_EOL, $lines));
68+
throw new \Exception('Failed to extract list of opened semaphores. Expected a "used arrays" key, got '.implode(PHP_EOL, $lines));
6069
}
6170

6271
return (int) $value;

0 commit comments

Comments
 (0)