mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-01 05:37:23 -06:00
Testkit: the temp_dir test pre-makes a private directory, as temp_dir does
a_temp_dir_starts_empty_in_a_process_and_stays_for_later_calls pre-created the "earlier process" directory with create_dir_all, which under a usual umask gives others access, so temp_dir refused it as not private and the test failed on every Unix run (main's CI included). The test now makes it with mode 0o700; temp_dir and the assertions are unchanged.
This commit is contained in:
@@ -111,7 +111,13 @@ mod tests {
|
||||
fn a_temp_dir_starts_empty_in_a_process_and_stays_for_later_calls() {
|
||||
let tag = "fresh-temp-dir";
|
||||
let left = std::env::temp_dir().join(format!("vectorcraft-testkit-{tag}-{}", std::process::id()));
|
||||
std::fs::create_dir_all(left.join("nested")).unwrap();
|
||||
// Made private, as `temp_dir` makes it: a directory others can reach is refused, not reused.
|
||||
#[cfg_attr(not(unix), allow(unused_mut))]
|
||||
let mut b = std::fs::DirBuilder::new();
|
||||
b.recursive(true);
|
||||
#[cfg(unix)]
|
||||
std::os::unix::fs::DirBuilderExt::mode(&mut b, 0o700);
|
||||
b.create(left.join("nested")).unwrap();
|
||||
std::fs::write(left.join("left.txt"), b"an earlier process").unwrap();
|
||||
let dir = super::temp_dir(tag);
|
||||
assert_eq!(dir, left);
|
||||
|
||||
Reference in New Issue
Block a user