Skip to content

Commit

Permalink
Important: skip_hidden is now false by default!
Browse files Browse the repository at this point in the history
  • Loading branch information
brmmm3 committed Oct 26, 2024
1 parent c14958b commit 7f186e2
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 13 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [2.7.3] - 2024-10-22

### Changed

- Important: `skip_hidden` is now `false` by default!

### Improved

- Update dependencies.
Expand Down
2 changes: 1 addition & 1 deletion scandir/src/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ impl Count {
options: Options {
root_path: check_and_expand_path(root_path)?,
sorted: false,
skip_hidden: true,
skip_hidden: false,
max_depth: usize::MAX,
max_file_cnt: usize::MAX,
dir_include: None,
Expand Down
2 changes: 1 addition & 1 deletion scandir/src/scandir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ impl Scandir {
options: Options {
root_path: check_and_expand_path(root_path)?,
sorted: false,
skip_hidden: true,
skip_hidden: false,
max_depth: usize::MAX,
max_file_cnt: usize::MAX,
dir_include: None,
Expand Down
23 changes: 22 additions & 1 deletion scandir/tests/count.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ fn test_count() -> Result<(), Error> {
assert!(count.errors.is_empty());
//assert!(count.duration > 0.0); --> Fails on MAC
assert_eq!(12, count.dirs);
assert_eq!(81, count.files);
assert_eq!(0, count.devices);
#[cfg(unix)]
{
assert_eq!(54, count.slinks);
assert_eq!(0, count.pipes);
}
assert_eq!(0, count.hlinks);
common::cleanup(temp_dir)
}

#[test]
fn test_count_skip_hidden() -> Result<(), Error> {
#[cfg(unix)]
let temp_dir = common::create_temp_file_tree(3, 3, 4, 5, 6, 7)?;
#[cfg(windows)]
let temp_dir = common::create_temp_file_tree(3, 3, 4, 5)?;
let count = Count::new(temp_dir.path())?.skip_hidden(true).collect()?;
assert!(count.errors.is_empty());
//assert!(count.duration > 0.0); --> Fails on MAC
assert_eq!(12, count.dirs);
assert_eq!(63, count.files);
assert_eq!(0, count.devices);
#[cfg(unix)]
Expand Down Expand Up @@ -42,6 +63,6 @@ fn test_count_extended() -> Result<(), Error> {
assert_eq!(54, count.slinks);
assert_eq!(63, count.pipes);
}
assert_eq!(27, count.hlinks);
assert_eq!(45, count.hlinks);
common::cleanup(temp_dir)
}
10 changes: 5 additions & 5 deletions scandir/tests/scandir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn test_scandir() -> Result<(), Error> {
let temp_dir = common::create_temp_file_tree(3, 3, 4, 5)?;
let entries = Scandir::new(temp_dir.path(), Some(true))?.collect()?;
#[cfg(unix)]
assert_eq!(192, entries.results.len());
assert_eq!(210, entries.results.len());
#[cfg(windows)]
assert_eq!(75, entries.results.len());
assert_eq!(0, entries.errors.len());
Expand All @@ -34,16 +34,16 @@ fn test_scandir() -> Result<(), Error> {
}

#[test]
fn test_scandir_not_skip_hidden() -> Result<(), Error> {
fn test_scandir_skip_hidden() -> Result<(), Error> {
#[cfg(unix)]
let temp_dir = common::create_temp_file_tree(3, 3, 4, 5, 6, 7)?;
#[cfg(windows)]
let temp_dir = common::create_temp_file_tree(3, 3, 4, 5)?;
let scandir = Scandir::new(temp_dir.path(), Some(true))?;
let mut scandir = scandir.skip_hidden(false);
let mut scandir = scandir.skip_hidden(true);
let entries = scandir.collect()?;
#[cfg(unix)]
assert_eq!(210, entries.results.len());
assert_eq!(192, entries.results.len());
#[cfg(windows)]
assert_eq!(93, entries.results.len());
assert_eq!(0, entries.errors.len());
Expand Down Expand Up @@ -73,7 +73,7 @@ fn test_scandir_extended() -> Result<(), Error> {
.return_type(ReturnType::Ext)
.collect()?;
#[cfg(unix)]
assert_eq!(192, entries.results.len());
assert_eq!(210, entries.results.len());
#[cfg(windows)]
assert_eq!(75, entries.results.len());
assert_eq!(0, entries.errors.len());
Expand Down
35 changes: 30 additions & 5 deletions scandir/tests/walk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,41 @@ fn test_walk() -> Result<(), Error> {
}

#[test]
fn test_walk_not_skip_hidden() -> Result<(), Error> {
fn test_walk_skip_hidden() -> Result<(), Error> {
#[cfg(unix)]
let temp_dir = common::create_temp_file_tree(3, 3, 4, 5, 6, 7)?;
#[cfg(windows)]
let temp_dir = common::create_temp_file_tree(3, 3, 4, 5)?;
let walk = Walk::new(temp_dir.path(), Some(true))?;
let mut walk = walk.skip_hidden(false);
let toc = walk.collect()?;
let toc = Walk::new(temp_dir.path(), Some(true))?
.skip_hidden(true)
.collect()?;
assert_eq!(12, toc.dirs.len());
assert_eq!(81, toc.files.len());
assert_eq!(63, toc.files.len());
#[cfg(unix)]
{
assert_eq!(54, toc.symlinks.len());
assert_eq!(63, toc.other.len());
}
#[cfg(windows)]
{
assert_eq!(0, toc.symlinks.len());
assert_eq!(0, toc.other.len());
}
assert_eq!(0, toc.errors.len());
common::cleanup(temp_dir)
}

#[test]
fn test_walk_extended() -> Result<(), Error> {
#[cfg(unix)]
let temp_dir = common::create_temp_file_tree(3, 3, 4, 5, 6, 7)?;
#[cfg(windows)]
let temp_dir = common::create_temp_file_tree(3, 3, 4, 5)?;
let toc = Walk::new(temp_dir.path(), Some(true))?
.extended(true)
.collect()?;
assert_eq!(12, toc.dirs.len());
assert_eq!(63, toc.files.len());
#[cfg(unix)]
{
assert_eq!(54, toc.symlinks.len());
Expand Down

0 comments on commit 7f186e2

Please sign in to comment.