Commit f9f25bf
authored
Reset the working directory of child processes we spawn on Windows. (#1212)
This PR modifies the Windows implementation of `spawnProcess()` so that
it sets the working directory of the new process to "C:\" (or
thereabouts). This prevents a race condition on Windows because that
system won't let you delete a directory if it's the working directory of
any process. See [The Old New
Thing](https://devblogs.microsoft.com/oldnewthing/20101109-00/?p=12323)
for a very on-the-nose blog post.
Note that we do not specify the value of the working directory in an
exit test body. A test should generally not rely on it anyway because it
is global state and any thread could change its value at any time.
I haven't written a unit test for this change because it's unclear what
I could write that would be easily verifiable, and because I don't know
what state I might perturb outside such a test by calling
`SetCurrentDirectory()`.
Resolves #1209.
(This is a speculative fix.)
### Checklist:
- [x] Code and documentation should follow the style of the [Style
Guide](https://github.com/apple/swift-testing/blob/main/Documentation/StyleGuide.md).
- [x] If public symbols are renamed or modified, DocC references should
be updated.1 parent 3c8e4e8 commit f9f25bf
File tree
3 files changed
+68
-4
lines changed- Sources/Testing
- ExitTests
- Support
- Tests/TestingTests/Support
3 files changed
+68
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
284 | 284 | | |
285 | 285 | | |
286 | 286 | | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
287 | 309 | | |
288 | 310 | | |
289 | 311 | | |
290 | 312 | | |
291 | 313 | | |
292 | 314 | | |
293 | | - | |
294 | | - | |
| 315 | + | |
| 316 | + | |
295 | 317 | | |
296 | 318 | | |
297 | 319 | | |
298 | 320 | | |
299 | | - | |
| 321 | + | |
300 | 322 | | |
301 | 323 | | |
302 | 324 | | |
303 | 325 | | |
304 | 326 | | |
305 | | - | |
| 327 | + | |
306 | 328 | | |
307 | 329 | | |
308 | 330 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
719 | 719 | | |
720 | 720 | | |
721 | 721 | | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
| 728 | + | |
| 729 | + | |
| 730 | + | |
| 731 | + | |
| 732 | + | |
| 733 | + | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
| 743 | + | |
| 744 | + | |
| 745 | + | |
| 746 | + | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
| 752 | + | |
722 | 753 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
201 | 201 | | |
202 | 202 | | |
203 | 203 | | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
204 | 215 | | |
205 | 216 | | |
206 | 217 | | |
| |||
0 commit comments