260915.1 · 24198d904a074f2943b2a3be925e53134c994734
fix: Better sanitizing
This refactors the sanitization code somewhat, to provide a couple benefits:
- Ensure we sanitize output in error messages (#2119), while not
escaping newlines from error messages.
- Avoids some unnecessary allocations and string copies
- Makes `print_error` a little nicer to use. As a macro, it avoids
needing a separate call to `format!`.
The main downside is added complexity.
Fixes: #2119
reading declarations
Changes to tests/testenv/. All files
@@ -196,6 +196,22 @@ impl TestEnv { Ok(broken_symlink_link) } + pub fn create_symlink<P: AsRef<Path>>(+ &mut self,+ target: P,+ link_path: P,+ ) -> io::Result<PathBuf> {+ let root = self.test_root();+ let target_path = root.join(target);+ let link_path = root.join(link_path);+ #[cfg(unix)]+ unix::fs::symlink(&target_path, &link_path)?;+ #[cfg(windows)]+ windows::fs::symlink_file(&target_path, &link_path)?;++ Ok(link_path)+ }+ /// Get the root directory for the tests. pub fn test_root(&self) -> PathBuf { self.temp_dir.path().to_path_buf()