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.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/test_util/src/fs.rs b/test_util/src/fs.rs
index 12750ffa4..f9443c9c5 100644
--- a/test_util/src/fs.rs
+++ b/test_util/src/fs.rs
@@ -11,6 +11,8 @@ use std::sync::Arc;
use anyhow::Context;
use lsp_types::Url;
+use crate::assertions::assert_wildcard_match;
+
/// Represents a path on the file system, which can be used
/// to perform specific actions.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
@@ -105,7 +107,7 @@ impl PathRef {
pub fn read_to_string_if_exists(&self) -> Result<String, anyhow::Error> {
fs::read_to_string(self)
- .with_context(|| format!("Could not find file: {}", self))
+ .with_context(|| format!("Could not read file: {}", self))
}
pub fn rename(&self, to: impl AsRef<Path>) {
@@ -195,6 +197,19 @@ impl PathRef {
Command::new("chmod").arg("555").arg(self).output().unwrap();
}
}
+
+ pub fn assert_matches_file(&self, wildcard_file: impl AsRef<Path>) -> &Self {
+ let wildcard_file = PathRef::new(wildcard_file);
+ println!("output path {}", wildcard_file);
+ let expected_text = wildcard_file.read_to_string();
+ self.assert_matches_text(&expected_text)
+ }
+
+ pub fn assert_matches_text(&self, wildcard_text: impl AsRef<str>) -> &Self {
+ let actual = self.read_to_string();
+ assert_wildcard_match(&actual, wildcard_text.as_ref());
+ self
+ }
}
#[cfg(not(windows))]