#folders #assert #testing

dev dircmp

Compare folders and return a diff for assertion

2 unstable releases

0.2.0 Nov 29, 2022
0.1.0 Nov 29, 2022

#1171 in Filesystem

Download history 686/week @ 2024-11-15 935/week @ 2024-11-22 1044/week @ 2024-11-29 401/week @ 2024-12-06 234/week @ 2024-12-13 88/week @ 2024-12-20 125/week @ 2024-12-27 291/week @ 2025-01-03 189/week @ 2025-01-10 110/week @ 2025-01-17 132/week @ 2025-01-24 201/week @ 2025-01-31 141/week @ 2025-02-07 157/week @ 2025-02-14 232/week @ 2025-02-21 337/week @ 2025-02-28

890 downloads per month
Used in 5 crates

Apache-2.0

8KB
122 lines

dircmp

github crates.io docs.rs build status

Compare two folders for the similarities and differences.

  • Two way comparison
  • File types (dir, symlink, etc.)
  • Content difference is based on hashing the files, so binaries are also good for comparison
  • Good for asserting in tests and for taking snapshot of difference or similarity

Dependency

[dependencies]
dircmp = "0.1.0"

Usage

Default usage:

let cmp = dircmp::Comparison::default();

let result = cmp
    .compare(
        Path::new("/tmp/a"),
        Path::new("/tmp/b"),
    )

Ignore components:

use regex::RegexSet;

let ignores = let set = RegexSet::new(&[
    r"foo",
    r"bar",
]).expect("should compile");

let cmp = dircmp::Comparison::new(ignores);

let result = cmp
    .compare(
        Path::new("/tmp/a"),
        Path::new("/tmp/b"),
    )

Copyright

Copyright (c) 2022 @jondot. See LICENSE for further details.

Dependencies

~3–11MB
~120K SLoC