diff options
author | Mengsheng Wu <37139489+CausingBrick@users.noreply.github.com> | 2024-07-05 14:16:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-05 08:16:16 +0200 |
commit | 1e80d3e3b2d4f3ad38733cb44fedc388f6c878e9 (patch) | |
tree | 1b6219e7b2302534e0a3264624886aeffd5ed211 /tests/by-util/test_ls.rs | |
parent | a18c1329947468e25680d4509affb1b760e575b0 (diff) |
ls: fix error sub dir output (#6521)
Closes #6492
Diffstat (limited to 'tests/by-util/test_ls.rs')
-rw-r--r-- | tests/by-util/test_ls.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index d9ccf7915..8eea0b88b 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -4595,6 +4595,49 @@ fn test_ls_hyperlink_dirs() { } #[test] +fn test_ls_hyperlink_recursive_dirs() { + let scene = TestScenario::new(util_name!()); + let at = &scene.fixtures; + let path = at.root_dir_resolved(); + let separator = std::path::MAIN_SEPARATOR_STR; + + let dir_a = "a"; + let dir_b = "b"; + at.mkdir(dir_a); + at.mkdir(format!("{dir_a}/{dir_b}")); + + let result = scene + .ucmd() + .arg("--hyperlink") + .arg("--recursive") + .arg(dir_a) + .succeeds(); + + macro_rules! assert_hyperlink { + ($line:expr, $expected:expr) => { + assert!(matches!($line, Some(l) if l.starts_with("\x1b]8;;file://") && l.ends_with($expected))); + }; + } + + let mut lines = result.stdout_str().lines(); + assert_hyperlink!( + lines.next(), + &format!("{path}{separator}{dir_a}\x07{dir_a}\x1b]8;;\x07:") + ); + assert_hyperlink!( + lines.next(), + &format!("{path}{separator}{dir_a}{separator}{dir_b}\x07{dir_b}\x1b]8;;\x07") + ); + assert!(matches!(lines.next(), Some(l) if l.is_empty())); + assert_hyperlink!( + lines.next(), + &format!( + "{path}{separator}{dir_a}{separator}{dir_b}\x07{dir_a}{separator}{dir_b}\x1b]8;;\x07:" + ) + ); +} + +#[test] fn test_ls_color_do_not_reset() { let scene: TestScenario = TestScenario::new(util_name!()); let at = &scene.fixtures; |