1 // Bare metal platforms usually have very small amounts of RAM
2 // (in the order of hundreds of KB)
3 pub const DEFAULT_BUF_SIZE: usize = if cfg!(target_os = "espidf") { 512 } else { 8 * 1024 };
6 #[allow(dead_code)] // not used on emscripten
10 use crate::path::{Path, PathBuf};
14 pub struct TempDir(PathBuf);
17 pub fn join(&self, path: &str) -> PathBuf {
18 let TempDir(ref p) = *self;
22 pub fn path(&self) -> &Path {
23 let TempDir(ref p) = *self;
28 impl Drop for TempDir {
30 // Gee, seeing how we're testing the fs module I sure hope that we
31 // at least implement this correctly!
32 let TempDir(ref p) = *self;
33 let result = fs::remove_dir_all(p);
34 // Avoid panicking while panicking as this causes the process to
35 // immediately abort, without displaying test results.
36 if !thread::panicking() {
42 #[track_caller] // for `test_rng`
43 pub fn tmpdir() -> TempDir {
44 let p = env::temp_dir();
45 let mut r = crate::test_helpers::test_rng();
46 let ret = p.join(&format!("rust-{}", r.next_u32()));
47 fs::create_dir(&ret).unwrap();