diff options
author | zwPapEr <zw.paper@gmail.com> | 2021-02-14 22:02:40 +0800 |
---|---|---|
committer | Abin Simon <abinsimon10@gmail.com> | 2021-02-15 09:33:59 +0530 |
commit | 0ca699ee2f9c951948d02c83b6c0a45190969e22 (patch) | |
tree | 440d9993438645ad9c75ba24d412028d1f210571 | |
parent | 36002a35acbf8bf77d111961c5e1112325ce80a6 (diff) |
display/tree: :mag: :sparkles: add test for tree with all not show self
Signed-off-by: zwPapEr <zw.paper@gmail.com>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | src/display.rs | 30 | ||||
-rw-r--r-- | tests/integration.rs | 18 |
3 files changed, 49 insertions, 0 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index a166bf9..7d364a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add support for `TIME_STYLE` environment variable from [999eagle](https://github.com/999eagle) - Add man page from [edneville](https://github.com/edneville) ### Changed +- Not showing `.` and `..` when `--tree` with `--all` from [zwpaper](https://github.com/zwpaper) [#477](https://github.com/Peltoche/lsd/issues/477) ### Fixed - Fix handling blocks passed without -l in cli from [meain](https://github.com/meain) diff --git a/src/display.rs b/src/display.rs index 80d4a7f..f1d0084 100644 --- a/src/display.rs +++ b/src/display.rs @@ -345,11 +345,14 @@ fn get_padding_rules(metas: &[Meta], flags: &Flags) -> HashMap<Block, usize> { #[cfg(test)] mod tests { use super::*; + use crate::app; use crate::color; use crate::color::Colors; use crate::icon; use crate::icon::Icons; use crate::meta::{FileType, Name}; + use crate::Config; + use assert_fs::prelude::*; use std::path::Path; #[test] @@ -485,4 +488,31 @@ mod tests { assert_eq!(get_visible_width(&output), *l); } } + + #[test] + fn test_display_tree_with_all() { + let argv = vec!["lsd", "--tree", "--all"]; + let matches = app::build().get_matches_from_safe(argv).unwrap(); + let flags = Flags::configure_from(&matches, &Config::with_none()).unwrap(); + + let dir = assert_fs::TempDir::new().unwrap(); + dir.child("one.d").create_dir_all().unwrap(); + dir.child("one.d/two").touch().unwrap(); + dir.child("one.d/.hidden").touch().unwrap(); + let metas = Meta::from_path(Path::new(dir.path()), false) + .unwrap() + .recurse_into(42, &flags) + .unwrap() + .unwrap(); + let output = inner_display_tree( + &metas, + &flags, + &Colors::new(color::Theme::NoColor), + &Icons::new(icon::Theme::NoIcon, " ".to_string()), + 0, + "", + ); + + assert_eq!("one.d\n├── .hidden\n└── two\n", output); + } } diff --git a/tests/integration.rs b/tests/integration.rs index 4fe280e..8d34eb6 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -415,6 +415,24 @@ fn test_tree() { } #[test] +fn test_tree_all_not_show_self() { + let tmp = tempdir(); + tmp.child("one").touch().unwrap(); + tmp.child("one.d").create_dir_all().unwrap(); + tmp.child("one.d/two").touch().unwrap(); + tmp.child("one.d/.hidden").touch().unwrap(); + + cmd() + .arg(tmp.path()) + .arg("--tree") + .arg("--all") + .assert() + .stdout( + predicate::str::is_match("├── one\n└── one.d\n ├── .hidden\n └── two\n$").unwrap(), + ); +} + +#[test] fn test_tree_d() { let tmp = tempdir(); tmp.child("one").touch().unwrap(); |