diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2023-06-26 21:53:17 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-26 15:53:17 -0400 |
commit | a8d472f88e79703b1890bfdc87d7a3bb20b21428 (patch) | |
tree | d2c2daf1261d6dbcce7852368550d56c134bc97e /test_util/src/fs.rs | |
parent | fa935e553a9ec37d39d2274432a00f1b465cef0f (diff) |
feat(lock): skip saving declaration files in the lockfile (#19447)
This is also a performance improvement because declaration file hashes
don't need to be stored in the lockfile.
Closes #19444
Diffstat (limited to 'test_util/src/fs.rs')
-rw-r--r-- | test_util/src/fs.rs | 17 |
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))] |