summaryrefslogtreecommitdiffstats
path: root/dom/webgpu/tests/cts/vendor/src/fs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'dom/webgpu/tests/cts/vendor/src/fs.rs')
-rw-r--r--dom/webgpu/tests/cts/vendor/src/fs.rs33
1 files changed, 24 insertions, 9 deletions
diff --git a/dom/webgpu/tests/cts/vendor/src/fs.rs b/dom/webgpu/tests/cts/vendor/src/fs.rs
index 31697f9758..3062f27cdb 100644
--- a/dom/webgpu/tests/cts/vendor/src/fs.rs
+++ b/dom/webgpu/tests/cts/vendor/src/fs.rs
@@ -245,15 +245,6 @@ impl Display for Child<'_> {
}
}
-pub(crate) fn existing_file<P>(path: P) -> P
-where
- P: AsRef<Path>,
-{
- let p = path.as_ref();
- assert!(p.is_file(), "{p:?} does not exist as a file");
- path
-}
-
pub(crate) fn copy_dir<P, Q>(source: P, dest: Q) -> miette::Result<()>
where
P: Display + AsRef<Path>,
@@ -297,6 +288,30 @@ where
})
}
+pub(crate) fn rename<P1, P2>(from: P1, to: P2) -> miette::Result<()>
+where
+ P1: AsRef<Path>,
+ P2: AsRef<Path>,
+{
+ fs::rename(&from, &to).into_diagnostic().wrap_err_with(|| {
+ format!(
+ "failed to rename {} to {}",
+ from.as_ref().display(),
+ to.as_ref().display()
+ )
+ })
+}
+
+pub(crate) fn try_exists<P>(path: P) -> miette::Result<bool>
+where
+ P: AsRef<Path>,
+{
+ let path = path.as_ref();
+ path.try_exists()
+ .into_diagnostic()
+ .wrap_err_with(|| format!("failed to check if path exists: {}", path.display()))
+}
+
pub(crate) fn create_dir_all<P>(path: P) -> miette::Result<()>
where
P: AsRef<Path>,