Details
Details
- Reviewers
Alphare - Group Reviewers
hg-reviewers - Commits
- rHGdb2bc9e667a1: rust: fix testing with $TMPDIR ≠ /tmp
Diff Detail
Diff Detail
- Repository
- rHG Mercurial
- Lint
Automatic diff as part of commit; lint not applicable. - Unit
Automatic diff as part of commit; unit tests not applicable.
Event Timeline
Comment Actions
What is this patch doing ? Should we add some comment in the code to explain the rationnal around the skip thingy ?
Comment Actions
Thinking about it some more, this should just use https://doc.rust-lang.org/std/path/struct.Path.html#method.strip_prefix
Comment Actions
It took me long enough to realise what that magic “2” meant and why the test was failing; I'm not comfortable with the logic there to do that refactoring.
Comment Actions
rust
- let buf = b.join("in_a").components().skip(2).collect::<PathBuf>();
+ let buf = b.join("in_a");
+ let buf = buf.strip_prefix(&base_dir_path.parent().unwrap()).unwrap();
eprintln!("buf: {}", buf.display());
let path = path_to_hg_path_buf(buf).unwrap();
assert_eq!(
auditor.audit_path(&path),
Err(HgPathError::TraversesSymbolicLink {
- path: path,
+ path,
symlink: path_to_hg_path_buf(
- b.components().skip(2).collect::<PathBuf>()
+ b.strip_prefix(&base_dir_path.parent().unwrap()).unwrap()
)
.unwrap()
})This does the trick. Do you want me to send the patch instead?