summaryrefslogtreecommitdiff
path: root/test_util/src/fs.rs
diff options
context:
space:
mode:
Diffstat (limited to 'test_util/src/fs.rs')
-rw-r--r--test_util/src/fs.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/test_util/src/fs.rs b/test_util/src/fs.rs
index 17620276b..0e47a7503 100644
--- a/test_util/src/fs.rs
+++ b/test_util/src/fs.rs
@@ -118,6 +118,10 @@ impl PathRef {
.with_context(|| format!("Could not read file: {}", self))
}
+ pub fn read_to_bytes_if_exists(&self) -> Result<Vec<u8>, anyhow::Error> {
+ fs::read(self).with_context(|| format!("Could not read file: {}", self))
+ }
+
pub fn read_json<TValue: DeserializeOwned>(&self) -> TValue {
serde_json::from_str(&self.read_to_string()).unwrap()
}