diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2024-05-03 17:31:12 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-03 17:31:12 -0400 |
commit | d81e97f92fe41d54e956104011fe0b1ba6c325eb (patch) | |
tree | 9eed8e491bbf1137a64dd9f6b9ad914232109401 /tests/util/server/src/fs.rs | |
parent | 121769844d4456b296e42d60794813da1b1472eb (diff) |
chore: maybe make watcher tests less flaky (#23683)
Closes #23637
Diffstat (limited to 'tests/util/server/src/fs.rs')
-rw-r--r-- | tests/util/server/src/fs.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/tests/util/server/src/fs.rs b/tests/util/server/src/fs.rs index b9ae81b49..558d25ffb 100644 --- a/tests/util/server/src/fs.rs +++ b/tests/util/server/src/fs.rs @@ -150,24 +150,29 @@ impl PathRef { .unwrap_or_else(|| panic!("JSON file was empty for {}", self)) } + #[track_caller] pub fn rename(&self, to: impl AsRef<Path>) { fs::rename(self, self.join(to)).unwrap(); } + #[track_caller] pub fn append(&self, text: impl AsRef<str>) { let mut file = OpenOptions::new().append(true).open(self).unwrap(); file.write_all(text.as_ref().as_bytes()).unwrap(); } + #[track_caller] pub fn write(&self, text: impl AsRef<[u8]>) { fs::write(self, text).unwrap(); } + #[track_caller] pub fn write_json<TValue: Serialize>(&self, value: &TValue) { let text = serde_json::to_string_pretty(value).unwrap(); self.write(text); } + #[track_caller] pub fn symlink_dir( &self, oldpath: impl AsRef<Path>, @@ -187,6 +192,7 @@ impl PathRef { } } + #[track_caller] pub fn symlink_file( &self, oldpath: impl AsRef<Path>, @@ -206,12 +212,14 @@ impl PathRef { } } + #[track_caller] pub fn read_dir(&self) -> fs::ReadDir { fs::read_dir(self.as_path()) .with_context(|| format!("Reading {}", self.as_path().display())) .unwrap() } + #[track_caller] pub fn copy(&self, to: &impl AsRef<Path>) { std::fs::copy(self.as_path(), to) .with_context(|| format!("Copying {} to {}", self, to.as_ref().display())) @@ -247,6 +255,7 @@ impl PathRef { } } + #[track_caller] pub fn make_dir_readonly(&self) { self.create_dir_all(); if cfg!(windows) { |