Skip to content

Commit 9055611

Browse files
committed
[Lock] Fix SemaphoreStoreTest on OS X
1 parent 7f9a262 commit 9055611

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)