Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.2k
unit tests that write files to cwd have racy failures #14968
Copy link
Copy link
Closed
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.This issue is limited in scope and/or knowledge of Zig internals.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Extracted from #14647.
zig/lib/std/os/test.zig
Lines 24 to 29 in b4d58e9
zig/lib/std/os/test.zig
Lines 173 to 181 in b4d58e9
zig/lib/std/os/test.zig
Lines 263 to 276 in b4d58e9
There are more in this file too.
These tests are all incorrect because they write garbage to the current working directory. This is racy because multiple instances of unit tests may be running at once (with different build options, or for different targets, for example).
An alternative solution to this would be to have the test runner create a new temporary directory for each independent unit test, and change to that directory as the current working directory before each unit test run. But that seems like a waste of (the computer's) time, so probably the tests should just be modified to not do problematic things.
Example failure: