[Updated] D11738: tests: run the whole hg-core/path_auditor test in a clean temp dir
pacien (Pacien)
phabricator at mercurial-scm.org
Tue Nov 9 14:30:37 UTC 2021
Closed by commit rHGab2dfc993b5c: tests: run the whole hg-core/path_auditor test in a clean temp dir (authored by pacien).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D11738?vs=31030&id=31035
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11738/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D11738
AFFECTED FILES
rust/hg-core/src/utils/path_auditor.rs
CHANGE DETAILS
diff --git a/rust/hg-core/src/utils/path_auditor.rs b/rust/hg-core/src/utils/path_auditor.rs
--- a/rust/hg-core/src/utils/path_auditor.rs
+++ b/rust/hg-core/src/utils/path_auditor.rs
@@ -180,12 +180,14 @@
#[cfg(test)]
mod tests {
use super::*;
- use crate::utils::files::get_path_from_bytes;
- use crate::utils::hg_path::path_to_hg_path_buf;
+ use std::fs::{create_dir, File};
+ use tempfile::tempdir;
#[test]
fn test_path_auditor() {
- let auditor = PathAuditor::new(get_path_from_bytes(b"/tmp"));
+ let base_dir = tempdir().unwrap();
+ let base_dir_path = base_dir.path();
+ let auditor = PathAuditor::new(base_dir_path);
let path = HgPath::new(b".hg/00changelog.i");
assert_eq!(
@@ -201,32 +203,20 @@
})
);
- use std::fs::{create_dir, File};
- use tempfile::tempdir;
-
- let base_dir = tempdir().unwrap();
- let base_dir_path = base_dir.path();
- let skip = base_dir_path.components().count() - 1;
- let a = base_dir_path.join("a");
- let b = base_dir_path.join("b");
- create_dir(&a).unwrap();
- let in_a_path = a.join("in_a");
- File::create(in_a_path).unwrap();
-
+ create_dir(&base_dir_path.join("realdir")).unwrap();
+ File::create(&base_dir_path.join("realdir/realfile")).unwrap();
// TODO make portable
- std::os::unix::fs::symlink(&a, &b).unwrap();
-
- let buf = b.join("in_a").components().skip(skip).collect::<PathBuf>();
- eprintln!("buf: {}", buf.display());
- let path = path_to_hg_path_buf(buf).unwrap();
+ std::os::unix::fs::symlink(
+ &base_dir_path.join("realdir"),
+ &base_dir_path.join("symlink"),
+ )
+ .unwrap();
+ let path = HgPath::new(b"symlink/realfile");
assert_eq!(
- auditor.audit_path(&path),
+ auditor.audit_path(path),
Err(HgPathError::TraversesSymbolicLink {
- path: path,
- symlink: path_to_hg_path_buf(
- b.components().skip(2).collect::<PathBuf>()
- )
- .unwrap()
+ path: path.to_owned(),
+ symlink: HgPathBuf::from_bytes(b"symlink"),
})
);
}
To: Alphare, #hg-reviewers
Cc: pacien, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20211109/298a08fb/attachment-0002.html>
More information about the Mercurial-patches
mailing list