File: 0002-Patch-out-tests-that-use-Eloquent-Liberator.patch

package info (click to toggle)
php-malkusch-lock 2.2.1%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 412 kB
  • sloc: php: 2,193; makefile: 19
file content (197 lines) | stat: -rw-r--r-- 6,193 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
From: James Valleroy <jvalleroy@mailbox.org>
Date: Thu, 30 Dec 2021 10:13:00 -0500
Subject: Patch out tests that use Eloquent\Liberator

Last upstream activity was in 2014, so it is not likely to be
packaged.

Forwarded: not-needed
---
 tests/mutex/FlockMutexTest.php       | 106 -----------------------------------
 tests/mutex/MutexConcurrencyTest.php |  17 ------
 tests/mutex/MutexTest.php            |  17 ------
 3 files changed, 140 deletions(-)
 delete mode 100644 tests/mutex/FlockMutexTest.php

diff --git a/tests/mutex/FlockMutexTest.php b/tests/mutex/FlockMutexTest.php
deleted file mode 100644
index a194563..0000000
--- a/tests/mutex/FlockMutexTest.php
+++ /dev/null
@@ -1,106 +0,0 @@
-<?php
-
-namespace malkusch\lock\mutex;
-
-use Eloquent\Liberator\Liberator;
-use malkusch\lock\exception\DeadlineException;
-use malkusch\lock\exception\TimeoutException;
-use malkusch\lock\util\PcntlTimeout;
-use PHPUnit\Framework\TestCase;
-
-/**
- * @author Willem Stuursma-Ruwen <willem@stuursma.name>
- * @link bitcoin:1P5FAZ4QhXCuwYPnLZdk3PJsqePbu1UDDA Donations
- * @license WTFPL
- * @see CASMutex
- */
-class FlockMutexTest extends TestCase
-{
-    /**
-     * @var FlockMutex
-     */
-    private $mutex;
-
-    /**
-     * @var string
-     */
-    private $file;
-
-    protected function setUp(): void
-    {
-        parent::setUp();
-
-        $this->file = tempnam(sys_get_temp_dir(), 'flock-');
-        $this->mutex = Liberator::liberate(new FlockMutex(fopen($this->file, 'r'), 1)); // @phpstan-ignore-line
-    }
-
-    protected function tearDown(): void
-    {
-        unlink($this->file);
-
-        parent::tearDown();
-    }
-
-    /**
-     * @dataProvider dpTimeoutableStrategies
-     */
-    public function testCodeExecutedOutsideLockIsNotThrown(int $strategy)
-    {
-        $this->mutex->strategy = $strategy; // @phpstan-ignore-line
-
-        $this->assertTrue($this->mutex->synchronized(function (): bool {
-            usleep(1100 * 1000);
-
-            return true;
-        }));
-    }
-
-    /**
-     * @dataProvider dpTimeoutableStrategies
-     */
-    public function testTimeoutOccurs(int $strategy)
-    {
-        $this->expectException(TimeoutException::class);
-        $this->expectExceptionMessage('Timeout of 1 seconds exceeded.');
-
-        $another_resource = fopen($this->file, 'r');
-        flock($another_resource, LOCK_EX);
-
-        $this->mutex->strategy = $strategy; // @phpstan-ignore-line
-
-        try {
-            $this->mutex->synchronized(
-                function () {
-                    $this->fail('Did not expect code to be executed');
-                }
-            );
-        } finally {
-            fclose($another_resource);
-        }
-    }
-
-    public function dpTimeoutableStrategies()
-    {
-        return [
-            [FlockMutex::STRATEGY_PCNTL],
-            [FlockMutex::STRATEGY_BUSY],
-        ];
-    }
-
-    public function testNoTimeoutWaitsForever()
-    {
-        $this->expectException(DeadlineException::class);
-
-        $another_resource = fopen($this->file, 'r');
-        flock($another_resource, LOCK_EX);
-
-        $this->mutex->strategy = FlockMutex::STRATEGY_BLOCK; // @phpstan-ignore-line
-
-        $timebox = new PcntlTimeout(1);
-        $timebox->timeBoxed(function () {
-            $this->mutex->synchronized(function (): void {
-                $this->fail('Did not expect code execution.');
-            });
-        });
-    }
-}
diff --git a/tests/mutex/MutexConcurrencyTest.php b/tests/mutex/MutexConcurrencyTest.php
index d3e4b7f..5ea7873 100644
--- a/tests/mutex/MutexConcurrencyTest.php
+++ b/tests/mutex/MutexConcurrencyTest.php
@@ -2,7 +2,6 @@
 
 namespace malkusch\lock\mutex;
 
-use Eloquent\Liberator\Liberator;
 use PHPUnit\Framework\Constraint\IsType;
 use PHPUnit\Framework\TestCase;
 use Predis\Client;
@@ -235,22 +234,6 @@ class MutexConcurrencyTest extends TestCase
                 return new FlockMutex($file);
             }],
 
-            'flockWithTimoutPcntl' => [function ($timeout = 3) use ($filename): Mutex {
-                $file = fopen($filename, 'w');
-                $lock = Liberator::liberate(new FlockMutex($file, $timeout));
-                $lock->stategy = FlockMutex::STRATEGY_PCNTL; // @phpstan-ignore-line
-
-                return $lock->popsValue();
-            }],
-
-            'flockWithTimoutBusy' => [function ($timeout = 3) use ($filename): Mutex {
-                $file = fopen($filename, 'w');
-                $lock = Liberator::liberate(new FlockMutex($file, $timeout));
-                $lock->stategy = FlockMutex::STRATEGY_BUSY; // @phpstan-ignore-line
-
-                return $lock->popsValue();
-            }],
-
             'semaphore' => [function ($timeout = 3) use ($filename): Mutex {
                 $semaphore = sem_get(ftok($filename, 'b'));
                 $this->assertThat(
diff --git a/tests/mutex/MutexTest.php b/tests/mutex/MutexTest.php
index d5d0437..b743bba 100644
--- a/tests/mutex/MutexTest.php
+++ b/tests/mutex/MutexTest.php
@@ -2,7 +2,6 @@
 
 namespace malkusch\lock\mutex;
 
-use Eloquent\Liberator\Liberator;
 use Memcached;
 use org\bovigo\vfs\vfsStream;
 use PHPUnit\Framework\TestCase;
@@ -56,22 +55,6 @@ class MutexTest extends TestCase
                 return new FlockMutex($file);
             }],
 
-            'flockWithTimoutPcntl' => [function (): Mutex {
-                $file = fopen(vfsStream::url('test/lock'), 'w');
-                $lock = Liberator::liberate(new FlockMutex($file, 3));
-                $lock->stategy = FlockMutex::STRATEGY_PCNTL; // @phpstan-ignore-line
-
-                return $lock->popsValue();
-            }],
-
-            'flockWithTimoutBusy' => [function ($timeout = 3): Mutex {
-                $file = fopen(vfsStream::url('test/lock'), 'w');
-                $lock = Liberator::liberate(new FlockMutex($file, 3));
-                $lock->stategy = FlockMutex::STRATEGY_BUSY; // @phpstan-ignore-line
-
-                return $lock->popsValue();
-            }],
-
             'SemaphoreMutex' => [function (): Mutex {
                 return new SemaphoreMutex(sem_get(ftok(__FILE__, 'a')));
             }],