Commit aadb165
committed
fix(pytest_plugin): unlink socket file on fixture teardown
The `server` and `TestServer` fixtures called `server.kill()` on
teardown but never unlinked the socket file under `/tmp/tmux-<uid>/`.
tmux does not reliably `unlink(2)` its own socket on non-graceful exit
— so every test run that used these fixtures left behind stale socket
entries that accumulated indefinitely (10k+ observed on long-lived
dev machines).
Introduce `_reap_test_server(socket_name)` helper that kills the
daemon (if alive) *and* unconditionally unlinks the computed socket
path. `Server(socket_name=...)` does not populate `socket_path`, so
the helper recomputes `$TMUX_TMPDIR/tmux-<uid>/<name>` the same way
tmux does. Both fixture finalizers delegate to it.
Cleanup errors are suppressed via `contextlib.suppress` so a
finalizer failure never masks the real test failure, and races with
pytest-xdist workers (concurrent access to the same directory) stay
benign. Kills ride through `LibTmuxException`/`OSError`; unlinks use
`missing_ok=True` and swallow `OSError`.
Added regression tests:
- `_reap_test_server` unlinks a real socket file after killing a live
daemon.
- Reaping a never-created socket is a silent no-op.
- Reaping `None` is tolerated for symmetry with `Server.socket_name`'s
nullable type.
Fixes #6601 parent 027c919 commit aadb165
3 files changed
Lines changed: 118 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
43 | 55 | | |
44 | 56 | | |
45 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 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 | + | |
27 | 61 | | |
28 | 62 | | |
29 | 63 | | |
| |||
141 | 175 | | |
142 | 176 | | |
143 | 177 | | |
144 | | - | |
| 178 | + | |
145 | 179 | | |
146 | 180 | | |
147 | 181 | | |
| |||
295 | 329 | | |
296 | 330 | | |
297 | 331 | | |
298 | | - | |
| 332 | + | |
299 | 333 | | |
300 | | - | |
301 | | - | |
302 | | - | |
| 334 | + | |
303 | 335 | | |
304 | 336 | | |
305 | 337 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
5 | 8 | | |
6 | 9 | | |
7 | 10 | | |
8 | 11 | | |
9 | | - | |
10 | | - | |
| 12 | + | |
| 13 | + | |
11 | 14 | | |
| 15 | + | |
12 | 16 | | |
13 | 17 | | |
14 | | - | |
15 | | - | |
16 | 18 | | |
17 | 19 | | |
18 | 20 | | |
| |||
156 | 158 | | |
157 | 159 | | |
158 | 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 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
0 commit comments