Expand description
Scratch folders: the rule every Rust test in the workspace keeps for what it writes outside its own memory. Its scratch is removed whatever happens: when it passes, fails or panics, and when a child it runs ends, aborts, overflows its stack or is killed. (Review round 9: a stack probe’s folder, made in a child its bisection overflows by design, outlived every such child; a test whose own process a mutant aborted left a chain of 996 folders; two tests removed their files only after their asserts.)
- Every scratch folder is a
Scratch, removed with what it holds when dropped, which a panic’s unwinding does too. No test namesstd::env::temp_dirbut this module (direct_scratchscans for it). - A child’s scratch is its parent’s.
crate::child::outputandcrate::child::statusmake a folder for each run of a child, name it in the child’sVAR, and remove it when the run ends, however it ends. A child that makes aScratch(this test binary run again as a probe, or a Python test throughtools/parity/scratch.py, which keeps the same rule) makes it inside that folder. A child that aborts or is killed runs no drop of its own, so its parent’s removal is the one that runs. - A process with no parent’s folder makes its folders in a root of
its own in the temp folder,
unityrs-test-<pid namespace>-<pid>, which goes with the last of them. A process that dies in its own code (an abort, a stack overflow, a kill) leaves its root behind, so the first folder any process makes removes every such root whose process no longer runs (sweep): a root is its own process’s alone, and only roots of this pid namespace are compared with its processes.
Owner: package B.
Structs§
- Scratch
- A new empty folder, removed with everything in it when dropped (module docs).
Constants§
- PREFIX
- The name of every process’s own root, before its pid namespace and pid.
- VAR
- The variable naming the folder a parent made for its child to make its scratch in (module docs).
Functions§
- direct_
scratch - Every place under
root(its.rsfiles,targetdirectories left out, this file too) that names the temp folder other than through this module: each line outside a//comment that namestemp_dir(). - remove_
tree - Removes
pathand everything under it a folder at a time, without following a link: a chain of folders past the stack or the open-file limit, and a folder of mode 000, go too. Nothing when it is not there. - sweep
- Removes every root in the temp folder of a process of this pid
namespace that no longer runs (module docs). Nothing on a system
without
/proc’s pid namespaces.