Skip to content

Commit 153577b

Browse files
committed
fix reflexivity
1 parent 3191d5c commit 153577b

File tree

7 files changed

+15
-3
lines changed

7 files changed

+15
-3
lines changed

src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ pub fn is_different<A: AsRef<Path>, B: AsRef<Path>>(a_base: A, b_base: B) -> Res
5353
return Ok(true);
5454
}
5555

56+
Ok(compare(&a_base, &b_base)? || compare(&b_base, &a_base)?)
57+
}
58+
59+
fn compare(a_base: &Path, b_base: &Path) -> Result<bool, Error> {
5660
// next, we walk all of the entries in a and compare them to b
5761
for entry in WalkDir::new(a_base) {
5862
let entry = entry?;
@@ -64,8 +68,6 @@ pub fn is_different<A: AsRef<Path>, B: AsRef<Path>>(a_base: A, b_base: B) -> Res
6468
// and then join that with b to get the path in b
6569
let b = b_base.join(no_prefix);
6670

67-
println!("comparing {} and {}", a.display(), b.display());
68-
6971
if a.is_dir() {
7072
if b.is_dir() {
7173
// can't compare the contents of directories, so just continue
@@ -91,7 +93,7 @@ pub fn is_different<A: AsRef<Path>, B: AsRef<Path>>(a_base: A, b_base: B) -> Res
9193
}
9294
}
9395

94-
// if we made it here, everything in a is in b!
96+
// if we made it here, we're good!
9597
Ok(false)
9698
}
9799

tests/reflexive/dir1/one.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
one
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
two

tests/reflexive/dir2/one.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
one
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
three
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
two

tests/smoke.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,9 @@ fn fileanddir() {
2828
#[test]
2929
fn oneempty() {
3030
assert!(dir_diff::is_different("tests/oneempty/dir1", "tests/oneempty/dir2").unwrap());
31+
}
32+
33+
#[test]
34+
fn reflexive() {
35+
assert!(dir_diff::is_different("tests/reflexive/dir1", "tests/reflexive/dir2").unwrap());
3136
}

0 commit comments

Comments
 (0)